# Event Loop

*noun*

say it: **“ih-VENT loop”** **/ɪˈvɛnt lup/**

The part of asyncio that runs async code: whenever one task is waiting, it switches to another that is ready, so one thread keeps many tasks moving.

## What is the **event loop**?

The **event loop** is the part of `asyncio` that runs async tasks. Whenever one task is waiting, it switches to another that's ready, so one thread keeps many tasks moving.

```python
import asyncio

async def brew(drink, seconds):
    await asyncio.sleep(seconds)
    print(f"{drink} ready")

async def main():
    await asyncio.gather(brew("tea", 2), brew("espresso", 1))

asyncio.run(main())   # espresso ready, then tea ready: 2 seconds total
```

## In a sentence

- “A time.sleep inside an async route froze the **event loop** for every request.”
- “The **event loop** ran the next request while the first waited on the movie service.”

Level: Master · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=5)

Updated: November 19, 2026

## In other subjects

- [Event Loop in JavaScript](https://www.ask-codey.com/glossary/event-loop-javascript)
- [Event Loop in Node.js](https://www.ask-codey.com/glossary/event-loop-nodejs)

Source: https://www.ask-codey.com/glossary/event-loop
