diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2018-11-25 09:29:47 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2018-11-25 09:29:47 +0100 |
commit | b0a66f3502b7959aed19c25dad1f2deb86f7208d (patch) | |
tree | 332b99727cc9579933d61f77c6456e883810cb9c /crocoite/cli.py | |
parent | 156ed72f8b27222e94f6363ba905cc38b95f2875 (diff) | |
download | crocoite-b0a66f3502b7959aed19c25dad1f2deb86f7208d.tar.gz crocoite-b0a66f3502b7959aed19c25dad1f2deb86f7208d.tar.bz2 crocoite-b0a66f3502b7959aed19c25dad1f2deb86f7208d.zip |
single: Graceful ^C
Allow cancellation of timeout wait.
Diffstat (limited to 'crocoite/cli.py')
-rw-r--r-- | crocoite/cli.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crocoite/cli.py b/crocoite/cli.py index e4a46ee..390cae6 100644 --- a/crocoite/cli.py +++ b/crocoite/cli.py @@ -69,7 +69,11 @@ def single (): service=service, handler=handler, behavior=b, logger=logger) try: loop = asyncio.get_event_loop() - loop.run_until_complete(controller.run ()) + run = asyncio.ensure_future (controller.run ()) + stop = lambda signum: run.cancel () + loop.add_signal_handler (signal.SIGINT, stop, signal.SIGINT) + loop.add_signal_handler (signal.SIGTERM, stop, signal.SIGTERM) + loop.run_until_complete(run) loop.close() ret = SingleExitStatus.Ok except Crashed: |