-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
GH-118095: Make sure that progress is made if there are pending calls being handled. #118484
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-118095: Make sure that progress is made if there are pending calls being handled. #118484
Conversation
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.
This makes sense. I have but one key question.
To avoid all threads constantly stopping on the eval breaker, | ||
we clear the bit for this thread and make sure it is set | ||
for the thread currently handling the pending call. */ | ||
_Py_set_eval_breaker_bit(pending->handling_thread, _PY_CALLS_TO_DO_BIT); | ||
_Py_unset_eval_breaker_bit(tstate, _PY_CALLS_TO_DO_BIT); |
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.
Does this mean that only the thread that was already handling pending calls will handle any remaining ones (until the queue is empty)? Currently the next available thread handles the remaining ones, so no single thread is blocked too long handling pending calls.
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.
Currently, the next available thread keeps tripping the eval breaker until the current call is handled, so the _PY_CALLS_TO_DO_BIT
is in effect blocking.
A non-blocking and fair mechanism would be good, but the current mechanism is neither.
This makes it non-blocking, although maybe less fair.
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.
That's fine. We can circle back to a fair mechanism later, if someone cares enough.
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.
LGTM
… calls being handled. (pythonGH-118484)
#118286 makes the assumption that
_Py_HandlePending()
will clear the eval_breaker, if not on the first call, then eventually.However, this isn't true for pending calls.
This PR makes sure that
_Py_HandlePending()
does eventually clear the eval_breaker.