Skip to content

fix(aio): drain blocked senders when closing channels - #7257

Open
Kuang-xianxin wants to merge 1 commit into
livekit:mainfrom
Kuang-xianxin:fix/channel-close-sender-cleanup
Open

fix(aio): drain blocked senders when closing channels#7257
Kuang-xianxin wants to merge 1 commit into
livekit:mainfrom
Kuang-xianxin:fix/channel-close-sender-cleanup

Conversation

@Kuang-xianxin

Copy link
Copy Markdown
Contributor

Closing a full bounded Chan wakes blocked senders but leaves their completed futures in _puts. A second close(), either immediately or after the senders finish, calls set_exception() on those futures and raises InvalidStateError during shutdown.

Drain the sender waiters when closing and only signal unfinished futures. Regression tests exercise both close timings through the public channel API, verify that all blocked senders receive ChanClosed, and that the buffered item remains readable.

Validation:

  • Both regressions fail on unchanged 34a4e8f; the 12 existing tests in test_aio.py pass there.
  • All 19 tests in tests/test_aio.py and tests/test_aio_itertools.py pass on Python 3.13.14.
  • Repository-wide Ruff checks and formatting (1,041 files), scoped Linux-target mypy for the channel module, and git diff --check pass.
  • The configured all-plugin type check stops at the local environment's missing livekit.plugins.anam py.typed marker, identically on the unchanged base. The full SDK/provider integration suite was not run locally.

@Kuang-xianxin
Kuang-xianxin requested a review from a team as a code owner September 13, 2026 05:31

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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