From c4b42000ebd4288ff8f8b99792d76dddfa0e388f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 28 Apr 2021 22:19:36 -0400 Subject: [PATCH] Shield around root actor cancel --- tractor/_root.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tractor/_root.py b/tractor/_root.py index 48ea462..8f4eb9a 100644 --- a/tractor/_root.py +++ b/tractor/_root.py @@ -169,10 +169,13 @@ async def open_root_actor( logger.exception("Actor crashed:") await _debug._maybe_enter_pm(err) + # always re-raise raise + finally: logger.info("Shutting down root actor") - await actor.cancel() + with trio.CancelScope(shield=True): + await actor.cancel() finally: _state._current_actor = None logger.info("Root actor terminated")