Commit 2589bb1b authored by Georgios Gousios's avatar Georgios Gousios
Browse files

Proper debug mode, correct channel shutdown sequence

parent 5704fff8
......@@ -53,8 +53,8 @@ class Dispatcher:
self._init()
[self.chan.basic_cancel(clienttag) for clienttag in self.clienttags]
self.chan.close()
self.chan.connection.close()
self.chan.close()
sys.exit()
def _init(self):
......@@ -182,6 +182,14 @@ def cleanup_queues() :
chan.connection.close()
def debug_mode(logger):
disp = Dispatcher(debug = True, logger = logger)
signal(SIGINT, _exit_handler)
signal(SIGTERM, _exit_handler)
disp.wait()
def main():
global children, logger
(opts, args) = parse_arguments(sys.argv[1:])
......@@ -202,6 +210,11 @@ def main():
cleanup_queues()
return
# Debug mode, process messages without spawning workers
if opts.debug:
debug_mode(logger = logger)
return
# Fork workers
children = []
......@@ -228,8 +241,9 @@ def main():
for pid in children:
try:
os.waitpid(pid)
except Exception:
pass
except Exception as e:
logger.error("Error waiting for child %d: %s"%(pid, e.message))
raise
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment