forked from goodboy/tractor
1
0
Fork 0

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.
msg_codecs
Tyler Goodlet 2024-03-29 19:15:50 -04:00
parent 3ba46362a9
commit 25ffdedc06
1 changed files with 5 additions and 2 deletions

View File

@ -190,11 +190,14 @@ class Lock:
is_trio_main = ( is_trio_main = (
# TODO: since this is private, @oremanj says # TODO: since this is private, @oremanj says
# we should just copy the impl for now.. # we should just copy the impl for now..
trio._util.is_main_thread() (is_main_thread := trio._util.is_main_thread())
and and
(async_lib := sniffio.current_async_library()) == 'trio' (async_lib := sniffio.current_async_library()) == 'trio'
) )
if not is_trio_main: if (
not is_trio_main
and is_main_thread
):
log.warning( log.warning(
f'Current async-lib detected by `sniffio`: {async_lib}\n' f'Current async-lib detected by `sniffio`: {async_lib}\n'
) )