Q26: How does asyncio execute concurrent I/O using an Event Loop?
asyncio uses single-threaded cooperative multitasking. An Event Loop manages a queue of pending tasks. Coroutines (async def) yield control explicitly using await, allowing the event loop to execute other ready tasks while waiting for I/O.
Key Takeaways
- Single-threaded cooperative concurrency.
- Use
awaiton asynchronous calls to yield loop execution to other tasks.
Knowledge Check
What happens if you execute a blocking synchronous function (like time.sleep(5)) inside an asyncio coroutine?