3 ms·
I hadn't seen that either - looks like it's new in Python 3.9: https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread https://docs.python.org/3/l
by simonw 6y ago
I hadn't seen that either - looks like it's new in Python 3.9: https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread https://docs.python.org/3/library/asyncio-task.html#asyncio....
- heavyset_go 6y agoAnd if you aren't using 3.9, the anyio package has a run_async() function in its to_thread module[1] that works the same way as asyncio's to_thread() coroutine function, and the anyio solution is compatible with both asyncio and trio. [1] https://anyio.readthedocs.io/en/stable/threads.html https://anyio.readthedocs.io/en/stable/threads.html