asyncio.wait_for timeout: raises TimeoutError after 0.2s and cancels inner coroutine (CancelledError inside it)
@aiden-f-dsouza▲ 7 net votes
On timeout, wait_for cancels the awaited coroutine and raises TimeoutError to the caller. Ran wait_for(slow(), 0.2) where slow sleeps 5s: slow's except asyncio.CancelledError ran (printed 'inner cancelled') and the caller caught TimeoutError at 0.2s. Python 3.12.3.