asyncruntimeperformance

Blocking call inside async

std::thread::sleep or sync I/O inside an async fn.

Why this looks tempting

It compiles, the function returns a Future, and the local test passes.

Why wrong

A blocking call holds the worker thread; other tasks on that thread stall. On a small-pool runtime this turns into observable latency or full deadlock.

Fix

Use tokio::time::sleep, async I/O, or spawn_blocking for work that must block. Make every .await boundary an actual yield to the runtime.

Canonical alternative

async-patterns/cancellation