diff options
| -rw-r--r-- | cron/qrunner | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/cron/qrunner b/cron/qrunner index 07ad9d0dc..64707ee9d 100644 --- a/cron/qrunner +++ b/cron/qrunner @@ -110,11 +110,16 @@ SNOOZE = mm_cfg.days(1) # cause a new StampedLogger to be opened the next time a message is logged. def sighup_handler(signum, frame): syslog.close() + # We also need to HUP all the child processes + for pid in KIDS.keys(): + os.kill(pid, signal.SIGHUP) # And just to tweak things... syslog('qrunner', 'qrunner caught SIGHUP. Re-opening log files.') signal.signal(signal.SIGHUP, sighup_handler) +KIDS = {} + def usage(code, msg=''): @@ -164,7 +169,6 @@ def start_lock_refresher(lock): def master(restart, lock): # Start up the lock refresher process watchdog_pid = start_lock_refresher(lock) - kids = {} # Start up all the qrunners for classname, count in mm_cfg.QRUNNERS: modulename = 'Mailman.Queue.' + classname @@ -173,7 +177,7 @@ def master(restart, lock): for slice in range(count): info = (qrclass, slice, count) pid = start_runner(*info) - kids[pid] = info + KIDS[pid] = info # # Now just wait for children to end, but also catch KeyboardInterrupts if restart: @@ -200,32 +204,32 @@ qrunner watchdog detected lock refresher exit if restart: watchdog_pid = start_lock_refresher(lock) else: - qrclass, slice, count = kids[pid] + qrclass, slice, count = KIDS[pid] syslog('qrunner', '''\ qrunner watchdog detected subprocess exit (pid: %d, sig: %d, sts: %d, class: %s, slice %d of %d) %s''' % (pid, killsig, exitstatus, qrclass, slice, count, restarting)) - del kids[pid] + del KIDS[pid] # Now perhaps restart the process if restart: newpid = start_runner(qrclass, slice, count) - kids[newpid] = (qrclass, slice, count) + KIDS[newpid] = (qrclass, slice, count) except KeyboardInterrupt: pass finally: # Should we leave the main loop for any reason, we want to be sure all # of our children are exited cleanly. Send SIGINTs to all the child # processes and wait for them all to exit. - for pid in kids.keys(): + for pid in KIDS.keys(): try: os.kill(pid, SIGINT) except OSError, e: if e.errno == errno.ESRCH: # The child has already exited - del kids[pid] + del KIDS[pid] # Wait for all the childred to go away - Utils.reap(kids) + Utils.reap(KIDS) |
