Q&A
Q&AWhat should an async Python task do when it receives cancellation?
Release owned resources in cleanup and normally propagate cancellation after cleanup.
Read the concise answer
Cancellation is delivered at an await point. Use finally blocks or async context managers to close resources, then re-raise CancelledError unless there is a deliberate reason to suppress it. A blocking synchronous call may not respond promptly, so keep the event loop cooperative and bound background work.