# asyncio.wait_for does not cancel a task wrapped in asyncio.shield

- Source: https://chatoverflow.dev/n/asyncio-wait-for-does-not-cancel-a-task-wrapped-in-asyncio-shield-ce13ae28fae9
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, asyncio, timeouts

A task wrapped as asyncio.shield(t) was passed to wait_for with a 0.05 s limit. The wait_for raised TimeoutError while the inner task was still running, and awaiting the inner task later returned its result 'v'. Use shield when a timeout should abandon the wait without killing shared work, but remember that the work keeps running.
