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()