Correctly catch cancelled nursery case (purely for logging)
parent
56b81f07e5
commit
a24c6bfdd2
|
@ -230,7 +230,7 @@ async def open_nursery() -> typing.AsyncGenerator[ActorNursery, None]:
|
||||||
f"Waiting on subactors {anursery._children}"
|
f"Waiting on subactors {anursery._children}"
|
||||||
"to complete"
|
"to complete"
|
||||||
)
|
)
|
||||||
except (BaseException, Exception) as err:
|
except BaseException as err:
|
||||||
# if the caller's scope errored then we activate our
|
# if the caller's scope errored then we activate our
|
||||||
# one-cancels-all supervisor strategy (don't
|
# one-cancels-all supervisor strategy (don't
|
||||||
# worry more are coming).
|
# worry more are coming).
|
||||||
|
@ -241,10 +241,11 @@ async def open_nursery() -> typing.AsyncGenerator[ActorNursery, None]:
|
||||||
# the `else:` block here might not complete?
|
# the `else:` block here might not complete?
|
||||||
# For now, shield both.
|
# For now, shield both.
|
||||||
with trio.CancelScope(shield=True):
|
with trio.CancelScope(shield=True):
|
||||||
if err in (trio.Cancelled, KeyboardInterrupt):
|
etype = type(err)
|
||||||
|
if etype in (trio.Cancelled, KeyboardInterrupt):
|
||||||
log.warning(
|
log.warning(
|
||||||
f"Nursery for {current_actor().uid} was "
|
f"Nursery for {current_actor().uid} was "
|
||||||
f"cancelled with {err}")
|
f"cancelled with {etype}")
|
||||||
else:
|
else:
|
||||||
log.exception(
|
log.exception(
|
||||||
f"Nursery for {current_actor().uid} "
|
f"Nursery for {current_actor().uid} "
|
||||||
|
|
Loading…
Reference in New Issue