Skip to content

fix(playback): catch CancelledError when draining futures on close - #103

Merged
randileeharper merged 1 commit into
mainfrom
fix/playback-close-cancelled-futures
Jun 28, 2026
Merged

fix(playback): catch CancelledError when draining futures on close#103
randileeharper merged 1 commit into
mainfrom
fix/playback-close-cancelled-futures

Conversation

@randileeharper

@randileeharper randileeharper commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the CI failure from #101 (issue #89).

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 when the snapshot's background thread hit the cancelled future before close() did.

Change

  • vesper/playback_controller.py: drop cancel_futures=True from shutdown(). Revert to plain shutdown(wait=False), which stops accepting new submissions but lets in-flight futures run to completion. The drain loop already handles waiting for them via future.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

…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
randileeharper force-pushed the fix/playback-close-cancelled-futures branch from 99a83b7 to 507e2b2 Compare June 28, 2026 17:41
@randileeharper
randileeharper merged commit 629a65e into main Jun 28, 2026
1 check passed
@randileeharper
randileeharper deleted the fix/playback-close-cancelled-futures branch June 28, 2026 17:43
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