Python concurrency interview questions

Threads, processes and asyncio, the GIL and free-threaded Python, races in async code, blocking calls, cancellation, limits and request context.

6 quick facts

– interview-ready · 12 questions in this topic

– of 12 tried

Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.

Questions

  1. The GIL, threads and processesPick the fix
  2. How asyncio worksPredict
  3. Blocking calls inside async codeFill the blank
  4. Race conditions in async codePredict
  5. Sharing state between threads safelyFill the blank
  6. Limiting concurrency with semaphoresPredict
  7. Cancellation and cleanup in asyncioPredict
  8. WSGI vs ASGI serversPredict
  1. Request-scoped context with contextvarsPredict
  2. Producer-consumer with asyncio.QueueOrder the steps
  3. Deadlocks with application locksPick the fix
  4. TaskGroup vs gatherPredict

Practise this topic

Flashcards · 18

Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.

Quick quiz · 12 questions

One exercise per question, checked as you go. Needs JavaScript.

Mock interview · 2 sets

Timed, out loud, then tick what you covered. Needs JavaScript.

Quick facts

Recall the answer first, then tap Show to check.

Sources: Topic outline informed by System Design Primer by Donne Martin and the Zalando RESTful API Guidelines, both licensed under CC BY 4.0. Every question and answer is written by Best Latest Apps. Credits and license