Merge pull request #1095 from danc86/handle-HaltServer-in-manage_workers

handle HaltServer in manage_workers
This commit is contained in:
Randall Leeds 2015-12-26 14:35:55 -08:00
commit 2ac41c406b

View File

@ -176,9 +176,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()
@ -198,21 +198,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"