liveBook · Manning

Event loop

An event loop is a runtime mechanism that repeatedly selects ready events or tasks and dispatches their associated work for execution.

How 11 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 →

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 asynchronous I/O across many connections without assigning separate resources to each connection.
How deep it goes
Works through a basic Rust polling loop and event dispatch, leaving OS-specific multiplexing behind a poll() method.
Examples
Uses socket readiness, timer expiry, request handling, and a Rust polling loop to illustrate dispatch.
What you can do after
Evaluate/understand when an event loop can keep an I/O-bound server responsive and why blocking handlers undermine it.

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 event handlers and cooperative tasks so a single-threaded server can respond to multiple clients.
How deep it goes
Works from a queued-event loop through select-based socket callbacks to ready-task scheduling, including blocking and cooperative-yield limits.
Examples
Uses queued knock-and-reply events, a select-based pizza server, and a coroutine-driven pizza server.
What you can do after
Build it from scratch as a Python event queue or socket-ready dispatcher, and diagnose handlers that block the loop.

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 →

Related concepts

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.