GIL basics
The GIL lets only one Python thread execute Python bytecode at a time in CPython.
- Affects CPU-bound threads
- I O waits still benefit
- Use multiprocessing for CPU-heavy work
GIL basics
Tagged with concurrency
The GIL lets only one Python thread execute Python bytecode at a time in CPython.
GIL basics
Threads are useful for I/O-bound concurrency, multiprocessing is better for CPU-bound parallel work in CPython, and `asyncio` organizes cooperative I/O with coroutines and `async`/`await`.
Threading, multiprocessing, asyncio, coroutines, `async`/`await`, the GIL, and concurrency vs parallelism
Use async endpoints when the work awaits non-blocking I O; sync endpoints are fine for CPU work or blocking libraries.
async and await in FastAPI