diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2019-01-27 10:19:37 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2019-01-27 10:19:37 +0100 |
commit | 51d7fa07c5db9a1015ef210089a911c19796bd79 (patch) | |
tree | 8e13175492df5fe573205883d02ab72c459a4cc9 | |
parent | 53ed7436f6eb16bd609e8fb2a4478bb737a3824a (diff) | |
download | crocoite-51d7fa07c5db9a1015ef210089a911c19796bd79.tar.gz crocoite-51d7fa07c5db9a1015ef210089a911c19796bd79.tar.bz2 crocoite-51d7fa07c5db9a1015ef210089a911c19796bd79.zip |
recursive: Avoid deadlock if unknown exception occurs
Kill the subprocess and make sure we retrieve exceptions from .fetch()
-rw-r--r-- | crocoite/controller.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crocoite/controller.py b/crocoite/controller.py index cbc6662..eb8908c 100644 --- a/crocoite/controller.py +++ b/crocoite/controller.py @@ -349,6 +349,9 @@ class RecursiveController: except asyncio.CancelledError: # graceful cancellation process.send_signal (signal.SIGINT) + except Exception as e: + process.kill () + raise e finally: code = await process.wait() if code == 0: @@ -382,6 +385,9 @@ class RecursiveController: done, pending = await asyncio.wait (self.running, return_when=asyncio.FIRST_COMPLETED) self.running.difference_update (done) + # propagate exceptions + for r in done: + r.result () except asyncio.CancelledError: self.logger.info ('cancel', uuid='d58154c8-ec27-40f2-ab9e-e25c1b21cd88', @@ -390,6 +396,9 @@ class RecursiveController: finally: done = await asyncio.gather (*self.running, return_exceptions=True) + # propagate exceptions + for r in done: + r.result () self.running = set () log () |