Skip to main content

Module blocking

Module blocking 

Source
Expand description

Running a blocking section from code that may be on an async worker.

A synchronous call that can take seconds (SQLite with a busy timeout, file I/O, per-process OS queries) must not run inline on a Tokio worker. It is not only that one worker that stops: the worker that happens to be driving the I/O driver stops polling it, and no other worker takes the driver over until that one parks again. For the length of the call no socket is serviced — the HTTP health endpoint included — while timers and already-queued tasks keep running, so the server looks alive in its logs and answers nothing. That is what the launcher’s liveness probe saw before it recycled srv. See docs/analysis/ANALYSIS_SRV_HTTP_STALL_IO_DRIVER_STARVATION_2026_09_26.md.

Functions§

off_async_worker
Run f, handing this worker’s other tasks (and the I/O driver, if it holds it) to another thread first when called on a multi-thread runtime worker.