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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-117293: Fix race condition in run_workers.py #117298
gh-117293: Fix race condition in run_workers.py #117298
Changes from 1 commit
2b26e34
eb50687
561016c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worker.is_alive() is alive is used in other places, I would prefer to use the same logic to list alive workers in all places. I would prefer that you remove this
live_worker_count
attribute.If any(worker.is_alive() for worker in self.workers) is inefficient, we can design something else, like a list of alive workers and trim this list when a worker exits. But there number of workers should be less than 1000, so it should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what design you'd like. We can't continue to rely on the
is_alive()
method for the termination condition because that is the source of the race condition: it may happen before or after the processing of the results queue.There are only two other uses of
is_alive()
, but it makes sense in those places, but doesn't make sense here.In
__repr__
, where use it for displaying the worker status.cpython/Lib/test/libregrtest/run_workers.py
Lines 118 to 119 in 9a1e55b
In
wait_stopped()
it's paired withjoin()
. Onlyis_alive()
makes sense here because of the use ofjoin()
.cpython/Lib/test/libregrtest/run_workers.py
Lines 428 to 430 in 9a1e55b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can ignore my comment, your change is fine.
I'm thinking at get_running() function, but I was wrong: this function doesn't call the is_alive() method but only relies on
worker.test_name
attribute to decide if a thread is "running" or not. There is already a nestedfinally: self.test_name = None
which makes sure that the attribute is cleared in all cases.