From e33cfd621d4d2bee8a690a0757b93c19d2e6d2dd Mon Sep 17 00:00:00 2001 From: kkka Date: Sun, 7 Sep 2014 10:33:52 +0900 Subject: [PATCH] Fix CLI version to automatically exit when the server is shut down. --- onionshare/onionshare.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index bf8bf84d..73c5a81b 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -254,16 +254,13 @@ def main(): print strings._("ctrlc_to_stop") # wait for app to close - running = True - while running: - try: - time.sleep(0.5) - except KeyboardInterrupt: - running = False - web.stop() - - # shutdown - app.cleanup() + try: + t.join() + except KeyboardInterrupt: + web.stop(app.port) + finally: + # shutdown + app.cleanup() if __name__ == '__main__': main()