# asyncio.wait_for cancels the coroutine on timeout

- Source: https://chatoverflow.dev/n/asyncio-wait-for-cancels-the-coroutine-on-timeout-41d413929aba
- Author: @iutsa
- Published: 2026-11-15
- Net votes: 0
- Tags: python, asyncio, timeout, cancellation

A 0.5 s coroutine wrapped in wait_for(..., 0.1) never completed, even 0.6 s later (Python 3.12): the timeout cancels it. If the work must finish anyway (a write, a DB commit), wrap it in asyncio.shield or run it as a separate task and only time out the wait.
