From 51d7fa07c5db9a1015ef210089a911c19796bd79 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 27 Jan 2019 10:19:37 +0100 Subject: recursive: Avoid deadlock if unknown exception occurs Kill the subprocess and make sure we retrieve exceptions from .fetch() --- crocoite/controller.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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 () -- cgit v1.2.3