Skip to main content
EuroPython logo

Demystifying AsyncIO: Building Your Own Event Loop in Python

Track:
Python Internals & Ecosystem
Type:
Talk
Level:
intermediate
Room:
Forum Hall
Start:
14:35 on 10 July 2024
Duration:
30 minutes

Abstract

AsyncIO has emerged as a vital tool in Python’s ecosystem, particularly in web development, IO-bound tasks, and network programming. However, its internal mechanics often remain obscure, even to seasoned Python developers. This talk aims to demystify AsyncIO by guiding you through creating your own event loop in Python, culminating in running a FastAPI application with it.

In this talk, we’ll build an event loop from scratch in Python, capable of running an HTTP server through a FastAPI application.

Plan:

  • Introduction to AsyncIO
  • Core Concepts: Deep dive into Event loop, Futures, Tasks, and coroutines
  • Hands-On Building: Constructing an event loop from scratch
    • Scheduling callbacks
    • Executing tasks and coroutines
    • Handling network calls
  • Practical Application: Running a FastAPI HTTP server with our loop
  • Performance Insights: Comparing our event loop with the fastest ones

By the end of this talk, you’ll be able to understand the internal workings of AsyncIO and create a basic event loop capable of running a FastAPI application.


Resources