From a24c6bfdd2813add33de598cf9578a2591503f6d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 3 Aug 2020 18:44:50 -0400 Subject: [PATCH] Correctly catch cancelled nursery case (purely for logging) --- tractor/_trionics.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tractor/_trionics.py b/tractor/_trionics.py index 82d2653..746960c 100644 --- a/tractor/_trionics.py +++ b/tractor/_trionics.py @@ -230,7 +230,7 @@ async def open_nursery() -> typing.AsyncGenerator[ActorNursery, None]: f"Waiting on subactors {anursery._children}" "to complete" ) - except (BaseException, Exception) as err: + except BaseException as err: # if the caller's scope errored then we activate our # one-cancels-all supervisor strategy (don't # worry more are coming). @@ -241,10 +241,11 @@ async def open_nursery() -> typing.AsyncGenerator[ActorNursery, None]: # the `else:` block here might not complete? # For now, shield both. with trio.CancelScope(shield=True): - if err in (trio.Cancelled, KeyboardInterrupt): + etype = type(err) + if etype in (trio.Cancelled, KeyboardInterrupt): log.warning( f"Nursery for {current_actor().uid} was " - f"cancelled with {err}") + f"cancelled with {etype}") else: log.exception( f"Nursery for {current_actor().uid} "