handle HaltServer in manage_workers

This commit is contained in:
Dan Callaghan 2015-08-11 17:08:03 +10:00
parent 89562c776e
commit d6429233d9

View File

@ -171,9 +171,9 @@ class Arbiter(object):
self.start() self.start()
util._setproctitle("master [%s]" % self.proc_name) util._setproctitle("master [%s]" % self.proc_name)
self.manage_workers() try:
while True: self.manage_workers()
try: while True:
sig = self.SIG_QUEUE.pop(0) if len(self.SIG_QUEUE) else None sig = self.SIG_QUEUE.pop(0) if len(self.SIG_QUEUE) else None
if sig is None: if sig is None:
self.sleep() self.sleep()
@ -193,21 +193,21 @@ class Arbiter(object):
self.log.info("Handling signal: %s", signame) self.log.info("Handling signal: %s", signame)
handler() handler()
self.wakeup() self.wakeup()
except StopIteration: except StopIteration:
self.halt() self.halt()
except KeyboardInterrupt: except KeyboardInterrupt:
self.halt() self.halt()
except HaltServer as inst: except HaltServer as inst:
self.halt(reason=inst.reason, exit_status=inst.exit_status) self.halt(reason=inst.reason, exit_status=inst.exit_status)
except SystemExit: except SystemExit:
raise raise
except Exception: except Exception:
self.log.info("Unhandled exception in main loop:\n%s", self.log.info("Unhandled exception in main loop:\n%s",
traceback.format_exc()) traceback.format_exc())
self.stop(False) self.stop(False)
if self.pidfile is not None: if self.pidfile is not None:
self.pidfile.unlink() self.pidfile.unlink()
sys.exit(-1) sys.exit(-1)
def handle_chld(self, sig, frame): def handle_chld(self, sig, frame):
"SIGCHLD handling" "SIGCHLD handling"