From 00a201d0f3fb4796286300fe7b16eda189afef7a Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 21 Nov 2017 20:25:21 -0200 Subject: [bug] ensure shutdown happens only after reactor start --- src/leap/soledad/server/app.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/leap/soledad/server') diff --git a/src/leap/soledad/server/app.py b/src/leap/soledad/server/app.py index cad4f31b..2004de1e 100644 --- a/src/leap/soledad/server/app.py +++ b/src/leap/soledad/server/app.py @@ -32,13 +32,14 @@ from leap.soledad.server import get_config logger = getLogger(__name__) +def _deferred_shutdown(status): + reactor.addSystemEventTrigger('after', 'shutdown', + os._exit, status) + reactor.stop() + + def _exit(status): - if reactor.running: - reactor.addSystemEventTrigger( - 'after', 'shutdown', os._exit, status) - reactor.stop() - else: - os._exit(status) + reactor.callWhenRunning(_deferred_shutdown, status) def _log_and_exit(failure): -- cgit v1.2.3