liveBook · Manning

Event loop

An event loop is a runtime mechanism that repeatedly selects and dispatches ready events, tasks, or callbacks for execution.

How 14 Manning books explain it

Python Concurrency with asyncio

An event loop is a control mechanism that repeatedly selects runnable work, executes it, and responds when suspended work becomes ready.

How it is used
Coordinates asyncio tasks so I/O-bound operations progress concurrently without stopping a single Python thread.
How deep it goes
Explains queues, suspension, socket selectors, timeouts, manual management, and a simplified custom implementation, while deferring production completeness.
Examples
Uses web requests, non-blocking socket selectors, asyncio echo servers, Tkinter loops, and a custom socket server.
What you can do after
Build and operate asyncio applications, schedule coroutines, manage loops, and diagnose blocking CPU-bound or I/O code.

Read how Python Concurrency with asyncio explains event loop →

JavaScript in Depth

The event loop is the scheduling mechanism that repeatedly selects queued work and dispatches it for execution in a JavaScript runtime.

How it is used
Coordinates scheduled JavaScript callbacks and helps explain execution-order surprises and performance delays.
How deep it goes
Explains queued events and run-to-completion, then applies queue behavior to starvation and diagnosis without specifying one universal runtime implementation.
Examples
Contrasts a callback-output puzzle across runtimes and module formats with cases where low aggregate CPU conceals a saturated loop.
What you can do after
Diagnose/debug with it by tracing callback ordering, recognizing microtask starvation, and separating event-loop saturation from process-wide CPU usage.

Read how JavaScript in Depth explains event loop →

Secrets of the JavaScript Ninja, Second Edition

A runtime scheduling mechanism that coordinates when queued events and callbacks are handled by an application.

How it is used
Coordinates event handlers and other browser work during interactive page execution.
How deep it goes
Builds from a single event queue to macrotask and microtask queues, then works through delayed timer execution.
Examples
Traces mousemove and click DOM updates and a queued click, timeout, and interval timing scenario.
What you can do after
Diagnose/debug why an event or timer handler waits despite its event occurring or its delay expiring.

Read how Secrets of the JavaScript Ninja, Second Edition explains event loop →

Latency

An event loop is a control-flow pattern that waits for events, detects activity from event sources, and dispatches events to handlers.

How it is used
Coordinates I/O-bound concurrent work and multiplexes operations across many connections while waiting for events.
How deep it goes
Develops the poll-dispatch-task cycle through a Rust loop sketch, OS notification interfaces, and nonblocking handler constraints.
Examples
Illustrates asynchronous database queries, socket-readiness events, and a Rust loop with scheduled tasks.
What you can do after
Evaluate event-loop designs by distinguishing safe idle polling from blocking handlers and considering future-related overhead.

Read how Latency explains event loop →

Grokking Concurrency

An event loop is a control-flow pattern that repeatedly waits for pending events, selects their handlers, and invokes those handlers.

How it is used
Coordinates callbacks and cooperative tasks so a server can handle multiple clients concurrently in one thread.
How deep it goes
Builds queue-based, socket-readiness, and coroutine-scheduling loops, then extends one with a thread pool; the final demonstration is not production-ready.
Examples
Uses knock-knock events, a Fibonacci coroutine, and successive pizza-server implementations to illustrate dispatch and scheduling.
What you can do after
Builds an event loop from scratch to dispatch callbacks or schedule cooperative coroutines in a server.

Read how Grokking Concurrency explains event loop →

The Joy of JavaScript

An event loop is a runtime scheduling mechanism that repeatedly dequeues and executes pending callbacks or tasks to drive asynchronous execution.

How it is used
Places the event loop behind callbacks, promises, and async/await as the scheduling model for asynchronous JavaScript.
How deep it goes
Explains the callback queue and interleaved scheduling at a high level, without detailing queue rules or engine internals.
Examples
Contrasts synchronous, callback-based, and promise-based Node.js file reads and considers a module using top-level await.
What you can do after
Evaluate/understand how asynchronous work can proceed alongside main code and why dependent modules wait at top-level await.

Read how The Joy of JavaScript explains event loop →

Build a Frontend Web Framework (From Scratch)

The JavaScript runtime mechanism that coordinates execution of synchronous code and queued asynchronous tasks.

How it is used
Coordinates asynchronous lifecycle hooks, scheduler jobs, user interactions, timers, and DOM rendering.
How deep it goes
Explains the execution stack, two queues, four cycle steps, and microtask priority without pursuing full specification detail.
Examples
Uses event listeners, timers, promise callbacks, lifecycle hooks, nextTick(), and scheduler jobs.
What you can do after
Evaluate asynchronous ordering and schedule lifecycle or update work using microtasks.

Read how Build a Frontend Web Framework (From Scratch) explains event loop →

Building LLM Applications with DSPy

An event loop schedules and runs asynchronous tasks, switching between them when they complete or suspend.

How it is used
Coordinates coroutine tasks, switching between them when a task completes or pauses at an await point.
How deep it goes
Explains task switching at await points and that only one task executes at a time.
Examples
Demonstrates two sleeping coroutines run with asyncio.gather(), with their results and elapsed time printed.
What you can do after
Apply via asyncio.run() to start an event loop and run coroutine tasks.

Read how Building LLM Applications with DSPy explains event loop →

Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi

An event loop is a control structure that repeatedly waits for input or events and dispatches corresponding handlers.

How it is used
Runs interactive Pygame controls and live camera applications that repeatedly receive input, process data, display results, and detect exit requests.
How deep it goes
Implements initialization, polling, dispatch, frame-rate control, exit handling, camera cleanup, and face processing without exploring lower-level scheduling internals.
Examples
Uses a Pygame event printer and a live camera preview that marks detected faces until window, Q, or Esc input ends execution.
What you can do after
Apply it via Pygame or cv2 to build responsive input handlers, camera previews, controlled exits, and reusable robot interaction loops.

Read how Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi explains event loop →

Spring in Action, Sixth Edition

An event loop is a concurrency mechanism that repeatedly receives events and dispatches their handlers, typically without dedicating a thread to each request.

How it is used
Uses event-driven request handling to improve scalability in reactive web applications and APIs.
How deep it goes
Explains request, callback, and completion-event flow, then contrasts event-loop handling with servlet-based multithreading.
Examples
Illustrates callbacks for intensive database and network operations and visualizes handling more requests with fewer threads.
What you can do after
Apply it via Spring WebFlux when building reactive APIs that use nonblocking asynchronous request handling.

Read how Spring in Action, Sixth Edition explains event loop →

Grokking Simplicity

A runtime mechanism that repeatedly retrieves queued events or callbacks and invokes them when the call stack is available.

How it is used
Coordinates browser events and asynchronous callbacks while isolating separate execution timelines.
How deep it goes
Defines jobs, callbacks, queue processing, and single-threaded execution, then traces a complete AJAX interaction.
Examples
Uses click handling, AJAX cart updates, nested dog-and-cat requests, and a dishwashing callback refactoring exercise.
What you can do after
Apply it via JavaScript callbacks to structure asynchronous results instead of relying on immediate return values.

Read how Grokking Simplicity explains event loop →

The Well-Grounded Python Developer: How the pros use Python and Flask

An event loop is a control structure that waits for events and repeatedly dispatches them for processing.

How it is used
Keeps a Flask web server responsive by waiting for incoming HTTP requests and dispatching them to defined routes.
How deep it goes
Defines event waiting and dispatch behavior, but stops short of showing the loop’s internal implementation.
Examples
Uses a Flask home route on port 5000 and an undefined /something route that produces a 404 response.
What you can do after
Operate a Flask server and understand how it remains active while waiting for requests.

Read how The Well-Grounded Python Developer: How the pros use Python and Flask explains event loop →

Acing the Frontend Interview

The event loop is the JavaScript runtime mechanism that schedules queued callbacks and other tasks for execution when the call stack is available.

How it is used
Supports responsive web applications during API requests, animations, and user interactions.
How deep it goes
Explains the call stack, task queues, microtasks, and macrotasks, then points toward concurrency architecture.
Examples
Uses API requests, animations, user interactions, and asynchronous ordering issues as practical contexts.
What you can do after
Evaluate/understand asynchronous execution, debug ordering issues, and explain concurrency trade-offs in interviews.

Read how Acing the Frontend Interview explains event loop →

Secrets of the JavaScript Ninja, Third Edition

An event loop is a mechanism that repeatedly processes queued tasks and callbacks to support asynchronous, event-driven execution.

How it is used
Explains how browser-side JavaScript responds to user actions and how queued callbacks run.
How deep it goes
Defines single-threaded queue processing and distinguishes prioritized microtasks from task-queue callbacks.
Examples
Contrasts end-of-script logging with a promise callback and a setTimeout callback.
What you can do after
Evaluate asynchronous callback order by comparing promise microtasks with setTimeout tasks.

Read how Secrets of the JavaScript Ninja, Third Edition explains event loop →

Also covered in

What to know first

Related concepts

Questions about event loop

What is event loop?

An event loop is a runtime mechanism that repeatedly selects and dispatches ready events, tasks, or callbacks for execution.

Which Manning books explain event loop?

Python Concurrency with asyncio, JavaScript in Depth, Secrets of the JavaScript Ninja, Second Edition, Latency, Grokking Concurrency, The Joy of JavaScript, Build a Frontend Web Framework (From Scratch), Building LLM Applications with DSPy and 6 more.

What should I know before learning event loop?

Manning books that teach event loop usually introduce asynchronous programming, thread, task and Document Object Model first.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.