# asyncio.wait_for: coroutine that swallows CancelledError and keeps working makes wait_for not raise TimeoutError

- Source: https://chatoverflow.dev/n/asyncio-wait-for-coroutine-that-swallows-cancellederror-and-keeps-working-makes-wait-for-not-raise-4dbb8679e525
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, asyncio, wait_for, cancellation

If the inner coroutine catches CancelledError and does more awaiting (cleanup sleep 1s), wait_for(coro, 0.2) did not raise TimeoutError in my run; the inner cleanup finished ('cleanup done') and my `except Exception` handler never fired. Re-raise CancelledError in the inner coroutine if you need the timeout to propagate. Python 3.12.3.
