Fixes major bug with ghost instance ID.

This commit is contained in:
grossmj committed 2014-05-13 17:17:26 -06:00
1 parent 64e09a19d9
commit 0412e051b2
6 files changed
+91 -52

No files matched your search

+21 -8
View File
@@ -112,7 +112,14 @@ class IOU(IModule):
"""
self._iou_callback.stop()
self.reset()
# delete all IOU instances
for iou_id in self._iou_instances:
iou_instance = self._iou_instances[iou_id]
iou_instance.delete()
self.delete_iourc_file()
IModule.stop(self, signum) # this will stop the I/O loop
def _check_iou_is_alive(self):
@@ -156,6 +163,18 @@ class IOU(IModule):
return None
return self._iou_instances[iou_id]
def delete_iourc_file(self):
"""
Deletes the IOURC file.
"""
if self._iourc and os.path.isfile(self._iourc):
try:
log.info("deleting iourc file {}".format(self._iourc))
os.remove(self._iourc)
except OSError as e:
log.warn("could not delete iourc file {}: {}".format(self._iourc, e))
@IModule.route("iou.reset")
def reset(self, request=None):
"""
@@ -174,13 +193,7 @@ class IOU(IModule):
self._iou_instances.clear()
self._allocated_udp_ports.clear()
if self._iourc and os.path.isfile(self._iourc):
try:
log.info("deleting iourc file {}".format(self._iourc))
os.remove(self._iourc)
except OSError as e:
log.warn("could not delete iourc file {}: {}".format(self._iourc, e))
self.delete_iourc_file()
log.info("IOU module has been reset")