[FIX] workers: process signals during graceful shutdown to allow force shutdown

Required after e17844c946 which
enabled graceful shutdown of workers, including the cron worker.
The latter may typically be busy on long-running tasks that
will not be aborted by a simple graceful shutdown request.

A typical shutdown sequence initiated by a daemon manager such
as start-stop-daemon will involve multiple SIGTERM signals to
ensure the process really stops in a timely manner.
This was not possible after e17844c946
if any cron worker was busy.
This commit is contained in:
Olivier Dony 2015-06-18 19:18:03 +02:00
parent d0e39720e3
commit e8e3f75727
1 changed files with 5 additions and 0 deletions

View File

@ -186,6 +186,11 @@ class Multicorn(object):
for pid in self.workers.keys():
self.worker_kill(pid, signal.SIGINT)
while self.workers and time.time() < limit:
try:
self.process_signals()
except KeyboardInterrupt:
_logger.info("Forced shutdown.")
break
self.process_zombie()
time.sleep(0.1)
else: