4 ms·
Based on my experience. At some places where there were no better alternatives, framework utilizes sync functions under the hood, such as some databases. Over
by vednig 2y ago
Based on my experience.
At some places where there were no better alternatives, framework utilizes sync functions under the hood, such as some databases.
Overall there are also places where functions are async running in sync bodies, but they're not running on main thread.
- whilenot-dev 2y agoTo 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-...