Skip to content

Commit 629a65e

Browse files
Merge pull request #103 from randileeharper/fix/playback-close-cancelled-futures
fix(playback): catch CancelledError when draining futures on close
2 parents 9d6fcec + 507e2b2 commit 629a65e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

vesper/playback_controller.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ def close(self) -> None:
102102
any in-flight playback_snapshot() fan-out to finish so worker threads
103103
are not orphaned and can't raise at interpreter shutdown (issue #89).
104104
"""
105-
# Stop accepting new submissions first. cancel_futures=True (3.9+)
106-
# drops not-yet-started tasks; started ones still run to completion.
107-
self._executor.shutdown(wait=False, cancel_futures=True)
105+
# Stop accepting new submissions. Do NOT use cancel_futures=True here:
106+
# playback_snapshot() is actively awaiting future.result() on the same
107+
# futures, and cancelling them would raise CancelledError inside the
108+
# snapshot call. The drain loop below handles waiting.
109+
self._executor.shutdown(wait=False)
108110
with self._pending_lock:
109111
pending = list(self._pending_futures)
110112
# Drain in-flight tasks with a short bounded timeout per future. If a

0 commit comments

Comments
 (0)