1

i am new to asyncio coding, i had a question about how to handle IO in the asyncio event loop.

Given some sort of asynchronous IO stream or session (aiologger, asynchronous sqlalchemy), whenever I await it to send or commit, the event loop jumps out of that local function and into some other function. Cant this lead to IO collisions, like I start a sqlalchemy session, await to add something and the event loop might hop on to another command which begins another session but the other session is already started. Can this even happen in a application because I doubt it does, and if it does how is it usually handled?

Kryptic Coconut
  • 159
  • 1
  • 10
  • 2
    it's usually handled using [synchronization primitives](https://docs.python.org/3/library/asyncio-sync.html), here's a simple explanation when and why to use then: https://stackoverflow.com/a/59697570/13131047 – Łukasz Kwieciński Jan 21 '22 at 08:37

0 Answers0