join ir.cron threads on SIGTERM for issue604

This commit is contained in:
Cédric Krier committed 2009-02-11 19:02:52 +01:00
1 parent d106175172
commit 5594bb4e11
1 file changed
+8
+8
View File
@@ -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()