FREE Python, inside out LESSON · Python, inside out
Choose the concurrency model
Async tasks, threads, processes, and backpressure
Concurrency is a workload decision before it is a Python feature.
Async tasks cooperate while waiting and work well when many operations spend time on non-blocking I/O. Threads share memory and can overlap blocking calls, while processes isolate memory and can run CPU-heavy Python work in parallel. Native extensions may change the picture. The right choice depends on where time is spent, how cancellation propagates, and which resource must be bounded.
Name the waiting, compute, ownership, and failure boundaries before choosing async, threads, or processes.
Unbounded concurrency is delayed failure.
Creating a task for every input can exhaust sockets, memory, rate limits, database pools, or the downstream service. Use bounded queues and semaphores, define timeouts and cancellation, and decide whether overload should wait, shed, batch, or degrade. Preserve task ownership so exceptions cannot disappear into background work.
Concurrency increases work in flight; capacity decides whether that is useful or destructive.