nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Mock Interviews
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

Questions
1 of 9
1How does Python's asyncio event loop achieve concurrency without using multiple threads?
2What is the difference between threading, multiprocessing, and asyncio, and when would you choose each?
3What causes a deadlock in multithreaded code, and how can it be avoided?
4Why does multiprocessing avoid the GIL problem, and what overhead does it introduce instead?
5Given the GIL, why can multithreading still improve performance for I/O-bound tasks but not CPU-bound tasks?
6What is the difference between async def and a regular function, and what does await actually do?
7How would you run CPU-bound work alongside an asyncio application without blocking the event loop?
8What is a race condition, and how would you prevent one using threading.Lock?
9What is the Global Interpreter Lock (GIL), and why does it exist in CPython?
PythonPython
Basics
Control Flow and Functions
Data Structures
Comprehensions & Functional Programming
Iterators, Generators & Decorators
Object-Oriented Programming
Exception Handling & Debugging
Concurrency & Parallelism
Performance & Optimization
Testing
Security
Modules, Packaging & Environment
Type Hinting & Modern Python
System Design & Architecture with Python
Best Practices & Design Patterns
Edge Cases & Tricky Interview Questions
01 / 09

How does Python's asyncio event loop achieve concurrency without using multiple threads?

Difficulty: 8/10
Asyncio, Event Loop, Cooperative Scheduling

Cooperative scheduling: coroutines yield at await points and the loop resumes ready tasks

asyncio is single-threaded cooperative multitasking. The event loop owns a ready queue of callbacks and a selector (epoll, kqueue, or IOCP) that reports when file descriptors are readable or writable. A coroutine runs until it hits an await on a future that is not yet done; it yields control back to the loop with a callback registered on that future. The loop then runs other ready callbacks. When the underlying IO completes, the future is marked done and its callback resumes the coroutine. Concurrency comes from overlapping waits, not from parallel execution: while one coroutine waits on the network, others run. That is why a single blocking call such as requests.get or time.sleep freezes the entire loop.

  1. 1

    The loop is created per thread via asyncio.run or get_event_loop; only one loop runs per thread by default.

  2. 2

    Tasks are scheduled coroutines; asyncio.create_task starts one immediately on the loop.

  3. 3

    Selectors from the selectors module provide the OS-level readiness notifications.

  4. 4

    asyncio.to_thread and run_in_executor move blocking work to a thread or process pool so the loop stays responsive.

  5. 5

    Trade-off: cooperative scheduling has low per-task overhead and no data races within the loop, but any blocking call stalls everything.

  6. 6

    Common mistake: calling time.sleep, requests, or a blocking database driver inside an async function. It blocks the entire service.

  7. 7

    Version note: asyncio.run was added in 3.7. Tasks have set_name and eager task factories were added in 3.12. The loop API is stable but some methods (get_event_loop in the main thread) changed behavior in 3.10 and 3.12.

Scenario Questions

0-2 years experience

  1. 1What happens to other tasks when one coroutine calls time.sleep(5)?
  2. 2What does asyncio.run do?

2-5 years experience

  1. 1You need to run a blocking SDK call inside an async handler. How do you do it safely?
  2. 2You have CPU work in an async route and latency spikes. What is the root cause and the fix?

5-8 years experience

  1. 1You need to bound concurrency to 50 concurrent outbound requests. How do you enforce that with asyncio?
  2. 2A third-party library calls time.sleep internally. How do you integrate it without freezing the loop?

8+ years experience

  1. 1Design an async service that mixes async IO, blocking SDK calls, and CPU work with bounded queues, cancellation, and graceful shutdown.
  2. 2Explain how the event loop, selectors, and OS-level readiness interact under high connection counts, and how to tune limits safely.

Follow-up Questions

  • What exactly does the loop do when every task is waiting on IO?
  • How would you detect that something is blocking the event loop in production?
Sharethis question

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.