Repository navigation
fix: wake session waiter timeout task on stop - #11349
Merged
zouyonghe merged 2 commits intoNov 24, 2026
Merged
Conversation
- Signal the active timeout wait when a session ends early. - Add a regression test and changelog entry.
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/core/utils/session_waiter.py" line_range="34-35" />
<code_context>
def stop(self, error: Exception | None = None) -> None:
"""立即结束这个会话"""
+ if self.current_event and not self.current_event.is_set():
+ self.current_event.set()
if not self.future.done():
if error:
</code_context>
<issue_to_address>
**Late keep leaves timeout task pending**
When a caller invokes `keep()` after another task has stopped the controller, `keep()` does not check whether the controller's future is already done, so it creates a new timeout task after the stop signal has passed; no later stop wakes that task, which remains pending until its deadline.
Make `keep()` return without creating a task when the controller is already stopped, or otherwise ensure stop state also covers subsequently created timeout tasks.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: astrbot/core/utils/session_waiter.py:35
Sakura520222
pushed a commit
to Sakura520222/PyaBot
that referenced
this pull request
Nov 24, 2026
* fix: wake session waiter timeout task on stop - Signal the active timeout wait when a session ends early. - Add a regression test and changelog entry. * fix: ignore keep on stopped sessions --------- Co-authored-by: 邹永赫 <1259085392@qq.com> (cherry picked from commit e3d8e53)
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
Verification
uv run pytest tests/unit/test_session_waiter_pipeline.py -q— 8 passed.uv run ruff check astrbot/core/utils/session_waiter.py tests/unit/test_session_waiter_pipeline.py— passed.uv run ruff format --check astrbot/core/utils/session_waiter.py tests/unit/test_session_waiter_pipeline.py— passed.Summary by Sourcery
Ensure stopped session waiters terminate their timeout handling promptly and cannot restart it.
Bug Fixes:
Tests: