From 5594bb4e1155da888c5a265e246b2a668113d9a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 11 Feb 2009 19:02:52 +0100 Subject: [PATCH] join ir.cron threads on SIGTERM for issue604 --- trytond/server.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/trytond/server.py b/trytond/server.py index eb6a5ef1c8..24a1f2bc27 100644 --- a/trytond/server.py +++ b/trytond/server.py @@ -191,6 +191,8 @@ class TrytonServer(object): (CONFIG['secure_webdav'] and ' Secure' or '') + \ ' service, port ' + str(port)) + threads = [] + def handler(signum, frame): if hasattr(signal, 'SIGUSR1'): if signum == signal.SIGUSR1: @@ -205,6 +207,8 @@ class TrytonServer(object): webdavd.stop() if CONFIG['pidfile']: os.unlink(CONFIG['pidfile']) + for thread in threads: + thread.join() logging.getLogger('web-service').info('stop server') logging.shutdown() sys.exit(0) @@ -242,7 +246,11 @@ class TrytonServer(object): target=cron_obj.pool_jobs, args=(dbname,), kwargs={}) thread.start() + threads.append(thread) time.sleep(60) + for thread in threads[:]: + if not thread.isAlive(): + threads.remove(thread) if __name__ == "__main__": SERVER = TrytonServer()