# CPython bug reports: asyncio.wait_for() timeout does not kill the awaited process ## Metadata | Field | Value | |---|---| | Institute | Molodetz Institute — Research & Retrieval Division | | Subject | async-pty-process-testing | | Document type | Source Dossier | | Tier | 1 | | Source title | bugs.python.org msg233486, and companion msg357930 | | Source URL | https://bugs.python.org/msg233486 | | Source publisher / author | Python core development bug tracker (bugs.python.org / BPO) | | Source type | other (official bug tracker message) | | Source date (published) | Unknown — not stated | | Date researched | 2026-10-09 | | Researched by | tai (agent), model: Claude Sonnet 5, on behalf of retoor | | Research method | web search synthesis | | Confidence | High | | Status | Active | ## Summary Official CPython bug tracker messages confirming that `asyncio.wait_for()` timing out does not, by itself, terminate the coroutine/process it was waiting on — the awaited operation can continue running in the background after the `TimeoutError` is raised to the caller. ## Key findings - A bug report describes `wait_for()` timing out while the process it was waiting on continued living in the background — the timeout only stops *waiting*, it does not reach into and stop the underlying operation. - This is documented as a known, discussed behavior in CPython's own bug tracker (two related messages), not a one-off misunderstanding. ## Pros / strengths - Primary-source, from the language's own bug tracker — about as authoritative as a finding in this subject gets. - Directly actionable: it tells you precisely what `wait_for()` does *not* do for you, closing a dangerous assumption gap. ## Cons / limitations / caveats - Only the two referenced messages were reviewed, not the full bug thread's eventual resolution or whether later Python versions changed this behavior. ## Relevance to tai This is the specific reason `tai_test.py.TestCase.execute()` never treats a caught `asyncio.TimeoutError` (from the `asyncio.wait_for(self.run(), timeout=self.timeout)` wrapping every test) as sufficient cleanup on its own. The `finally` block unconditionally calls `await proc.terminate()` for every spawned process, precisely because this source confirms the timeout itself does nothing to stop the process — only the explicit `terminate()` call (with its own `killpg` escalation and reap) does. ## Changelog | Date | Change | |---|---| | 2026-10-09 | Initial dossier created. |