Concurrency · interview question
What is the healthiest performance judgment around semaphores, timeouts, and cancellation?
Multiple choiceMediumchapter-15-curatedpremiumconcurrencysemaphores-timeouts-and-cancellation
semaphore = asyncio.Semaphore(10)
async with semaphore:
await asyncio.wait_for(fetch_order("ORD-1"), timeout=2.0)Answer and explanation
Correct answer
C. Measure before optimizing, then change the part that actually dominates cost instead of guessing from style alone.
Why
Premature optimization is usually weaker than targeted optimization backed by measurement.
Test yourself on Concurrency
A free test with instant, explained results. No account needed.
More Concurrency questions
- What kind of contract clarity matters most for task coordination?
- What production risk should you worry about most if task coordination is handled lazily?
- A senior interviewer asks for one tradeoff behind semaphores, timeouts, and cancellation. What is the strongest…
- Which explanation would sound strongest in an interview when discussing threads for blocking i/o?
- Another engineer will maintain this code later. What choice helps the most around semaphores, timeouts, and…
- What kind of contract clarity matters most for threads for blocking i/o?