runtime
386 / 500
question 386 Async Python · medium

Fix the worker that can't be stopped

At shutdown the server cancels its background heartbeat task and waits for it, but the task never reports as cancelled: it catches the cancellation, logs it, and returns normally. Fix it so it still logs "stopped" but ends cancelled.

Coroutineasync def heartbeat(log, every): appends "beat" every every seconds forever
On cancellationappend "stopped", then let the cancellation continue (the task ends cancelled)

Loading your progress…

Fix the worker that can't be stopped — Python practice · Runtime