fix(playback): catch CancelledError when draining futures on close - #103
Merged
Conversation
…snapshot close() used shutdown(wait=False, cancel_futures=True), which cancels not-yet-started futures. But playback_snapshot() running concurrently is actively awaiting future.result() on those same futures — cancelling them raises CancelledError inside the snapshot call, not just in close()'s drain loop. On slower CI runners this surfaced as a test failure. Drop cancel_futures=True. The drain loop already handles waiting for in-flight futures to complete; cancellation is unnecessary and harmful here.
randileeharper
force-pushed
the
fix/playback-close-cancelled-futures
branch
from
June 28, 2026 17:41
99a83b7 to
507e2b2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the CI failure from #101 (issue #89).
close()usedshutdown(wait=False, cancel_futures=True), which cancels not-yet-started futures. Butplayback_snapshot()running concurrently is actively awaitingfuture.result()on those same futures — cancelling them raisesCancelledErrorinside the snapshot call, not just inclose()'s drain loop. On slower CI runners this surfaced as a test failure when the snapshot's background thread hit the cancelled future beforeclose()did.Change
vesper/playback_controller.py: dropcancel_futures=Truefromshutdown(). Revert to plainshutdown(wait=False), which stops accepting new submissions but lets in-flight futures run to completion. The drain loop already handles waiting for them viafuture.result(timeout=...)— cancellation was unnecessary and harmful here.Test commands run
.venv/bin/python -m pytest -q # 5 consecutive runs, all 255 passed .venv/bin/python -m compileall vesper tests