Backend development

Stage 1 · Lesson 6 of 10

asyncio, threads and the GIL

Your language and how HTTP works

A backend spends much of its time waiting on I/O (input and output, such as network calls). Python gives you two ways to do other work while waiting. The first is , where the operating system switches between tasks.

In standard , the (the GIL) lets only one thread run Python code at a time. But a thread that is waiting on I/O releases it, so threads still help with network calls. The second way is , which runs many (pausable functions) on one thread.

async def defines one, await hands control back while it waits, and asyncio.gather runs several at once. FastAPI builds on asyncio, and Django supports async views.

Common trapcalling blocking code, such as requests or time.sleep, inside an async function: it freezes the whole event loop, so every other request waits too.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

  • Your language track: small exercises with free mentor feedback on idiomatic code

Keep handy

  • Quick syntax lookups for your language when you forget how something is written

  • Read the HTTP overview, methods, headers and status code pages until they feel obvious

Also worth your time

Mark this stage as not done?