You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using to_thread.run_sync and then calling back again to the event loop with from_thread.run_sync I can't create an anyio.Event since sniffio fails to detect the running loop (no current_task is set in asyncio which of course is kindof true).
This is not critical for us and can be worked around by creating asyncio.Event objects directly (not ideal to tie to backend but ok in our case) or by making the function async which I would want to avoid since it doesn't really yield to the event loop or await anything.
from_thread here is really just used to ensure thread safety since the method modifies some other state that isn't explicitly locked but relies on only being modified by the main thread running the loop.
I don't know about triobut at least in asyncio it has been ok to create Event objects outside async contexts and also in different event loops as they don't actually bind to a loop until waited upon since 3.9
Repository owner
locked and limited conversation to collaborators
Nov 16, 2022
When using
to_thread.run_sync
and then calling back again to the event loop withfrom_thread.run_sync
I can't create ananyio.Event
since sniffio fails to detect the running loop (no current_task is set in asyncio which of course is kindof true).Reproduced in a gist here https://gist.github.com/tapetersen/e85a808f0bba7dd396fa68eafb41012d
The text was updated successfully, but these errors were encountered: