From a573c3c9a837ccfc2ec88d77cfa06585e385f1e0 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 7 May 2025 10:41:59 -0400 Subject: [PATCH] Unset debug-mode on root actor exit Discovered this bug while testing `modden`'s daemon under various cancelled-while-booting race conditions where sequential tests would fail a lingering `assert 0` inside `.to_asyncio.run_as_asyncio_guest()` to (oddly) catch redundant greenback-re-inits.. XD Needs a test likely ;P --- tractor/_root.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tractor/_root.py b/tractor/_root.py index 81ff884b..d6d5d697 100644 --- a/tractor/_root.py +++ b/tractor/_root.py @@ -281,7 +281,8 @@ async def open_root_actor( if ( debug_mode - and _spawn._spawn_method == 'trio' + and + _spawn._spawn_method == 'trio' ): _state._runtime_vars['_debug_mode'] = True @@ -517,8 +518,17 @@ async def open_root_actor( ) await actor.cancel(None) # self cancel finally: + # revert all process-global runtime state + if ( + debug_mode + and + _spawn._spawn_method == 'trio' + ): + _state._runtime_vars['_debug_mode'] = False + _state._current_actor = None _state._last_actor_terminated = actor + logger.runtime( f'Root actor terminated\n' f')>\n'