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/controller.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/controller.py')
-rw-r--r-- | crocoite/controller.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crocoite/controller.py b/crocoite/controller.py index 4d95b09..5f4fe10 100644 --- a/crocoite/controller.py +++ b/crocoite/controller.py @@ -178,7 +178,14 @@ class SinglePageController: idleTimeout = None while True: idleProc = asyncio.ensure_future (l.idle.wait ()) - finished, pending = await asyncio.wait([idleProc, timeoutProc], return_when=asyncio.FIRST_COMPLETED, timeout=idleTimeout) + try: + finished, pending = await asyncio.wait([idleProc, timeoutProc], + return_when=asyncio.FIRST_COMPLETED, timeout=idleTimeout) + except asyncio.CancelledError: + idleProc.cancel () + timeoutProc.cancel () + break + if not finished: # idle timeout idleProc.cancel () |