note that from_thread.run(_sync)? does set sniffio on trio, however.
this causes a few bugs:
-
from_thread.run(_sync)? fails when used to call sniffio-dependent functions when the to_thread worker is running a non-asyncio async backend known to sniffio (i.e. trio, curio, or (situationally) trio-asyncio) and the thread that started the worker is on asyncio.
reproducer: bc3cc49.
-
because BlockingPortal._spawn_task_from_thread shares its underlying implementation with from_thread.run_sync on asyncio, using a BlockingPortal that was started by start_blocking_portal("asyncio") in a non-asyncio async backend known to sniffio deadlocks.
reproducer: cd9deb1.
note that
from_thread.run(_sync)?does set sniffio on trio, however.this causes a few bugs:
from_thread.run(_sync)?fails when used to call sniffio-dependent functions when theto_threadworker is running a non-asyncio async backend known to sniffio (i.e. trio, curio, or (situationally) trio-asyncio) and the thread that started the worker is on asyncio.reproducer: bc3cc49.
because
BlockingPortal._spawn_task_from_threadshares its underlying implementation withfrom_thread.run_syncon asyncio, using aBlockingPortalthat was started bystart_blocking_portal("asyncio")in a non-asyncio async backend known to sniffio deadlocks.reproducer: cd9deb1.