From 25ffdedc0682edf112029ccfe4249a4aa342be7a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 29 Mar 2024 19:15:50 -0400 Subject: [PATCH] Oof, fix walrus assign causes name-error edge case Only warn log on a non-`trio` async lib when in the main thread to avoid a name error when in the non-`asyncio` non-main-thread case. => To cherry into the `.pause_from_sync()` feature branch. --- tractor/devx/_debug.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tractor/devx/_debug.py b/tractor/devx/_debug.py index 75be7a2..255b1db 100644 --- a/tractor/devx/_debug.py +++ b/tractor/devx/_debug.py @@ -190,11 +190,14 @@ class Lock: is_trio_main = ( # TODO: since this is private, @oremanj says # we should just copy the impl for now.. - trio._util.is_main_thread() + (is_main_thread := trio._util.is_main_thread()) and (async_lib := sniffio.current_async_library()) == 'trio' ) - if not is_trio_main: + if ( + not is_trio_main + and is_main_thread + ): log.warning( f'Current async-lib detected by `sniffio`: {async_lib}\n' )