Skip to content

Fix QTMProtocol.event_future leak on await_event timeout#60

Open
ulvs wants to merge 1 commit into
masterfrom
fix_await_event_timeout
Open

Fix QTMProtocol.event_future leak on await_event timeout#60
ulvs wants to merge 1 commit into
masterfrom
fix_await_event_timeout

Conversation

@ulvs

@ulvs ulvs commented Jun 11, 2026

Copy link
Copy Markdown
Member

asyncio.wait_for cancels _wait_loop on timeout but event_future stays set. The next await_event call then sees it and raises Can't wait on multiple events! even though nothing is being awaited.

Wraps wait_for in try/finally and clears event_future on the way out. On success _on_event already cleared it; the assignment is a no-op.

Adds a test_await_event_after_timeout regression test.

asyncio.wait_for cancels _wait_loop on timeout but the queued
event_future stays referenced. The next await_event call then sees
event_future is not None and raises "Can't wait on multiple events!"
even though no event is actually being awaited.

Wrap the wait_for in try/finally and clear event_future on the way out.
On success _on_event already cleared it; assignment is a no-op.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant