Test waiter leak on timeout - #1674
Merged
clalancette merged 2 commits intoJun 2, 2026
Merged
Conversation
Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
fujitatomoya
approved these changes
May 30, 2026
fujitatomoya
left a comment
Collaborator
There was a problem hiding this comment.
lgtm.
a thread that added itself to _waiting_threads and then timed out never removed itself. a leaked entry makes a future wait() from another thread see the predicate satisfied prematurely. it returns True (drained) while a callback is still genuinely in flight.
Comment on lines
+190
to
+193
| if not drained or (added_self and current not in self._executing_thread_counts): | ||
| if added_self: | ||
| self._waiting_threads.discard(current) | ||
| self._work_condition.notify_all() |
Collaborator
There was a problem hiding this comment.
nit; can be simplified?
Suggested change
| if not drained or (added_self and current not in self._executing_thread_counts): | |
| if added_self: | |
| self._waiting_threads.discard(current) | |
| self._work_condition.notify_all() | |
| if added_self and (not drained or current not in self._executing_thread_counts): | |
| self._waiting_threads.discard(current) | |
| self._work_condition.notify_all() |
Contributor
There was a problem hiding this comment.
I'll do this simplification over on the other PR.
clalancette
merged commit Jun 2, 2026
e532007
into
clalancette/fix-immediate-shutdown
3 checks passed
clalancette
pushed a commit
that referenced
this pull request
Jun 2, 2026
* Add test case for _WorkTracker waiter membership leak on timeout Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com> * Fix waiter membership leak in _WorkTracker.wait on timeout Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com> --------- Signed-off-by: Michael Carroll <mjcarroll.oss@gmail.com>
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.
Description
Test and fix for a race condition I found in #1666
More context specifically here: #1666 (comment)
Running with the first commit (test only) and it fails. Run with fix and it passes.
Did you use Generative AI?
Assisted-by: Gemini CLI:Gemini 3.5 Flash