2 ms·
To GP: yes, it would block the event loop and that's pretty bad. But... asyncio.to_thread[0] as a quick workaround, just keep track of your thread count. Obvio
by whilenot-dev 2y ago
To GP: yes, it would block the event loop and that's pretty bad. But...
asyncio.to_thread[0] as a quick workaround, just keep track of your thread count. Obviously frameworks and libraries with asyncio support should be chosen whenever possible.
> Overall there are also places where functions are async running in sync bodies, but they're not running on main thread.
That would be a design mistake, as functions have colors[1] with async/await. That's currently my biggest gripe in the python ecosystem, apart from modules maintaining their own hidden state.
[0]: https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread https://docs.python.org/3/library/asyncio-task.html#asyncio....
[1]: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...