-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-116143: Fix race condition in pydoc _start_server #116144
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
Conversation
itamaro
commented
Feb 29, 2024
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Issue: Race condition in pydoc._start_server #116143
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 is great, thanks! Would it be possible to add a test for this as well?
Thank you! I'm not sure about a specific test for this scenario. The existing |
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.
It looks like thread.serving
will always be set before thread.docserver
. It's set in the thread.ready()
callback, which is called in DocServer.server_activate
, which is called from TCPServer.__init__
, so it will definitely happen -- barring an error occurring instead -- before the DocServer(...)
initialization returns. So there's not a race condition in the attributes being set, the window is always there; the race is just a matter of whether we get a thread context switch such that _start_server
catches that window and is able to return during it.
This change fixes the bug, and looks like the minimal effective fix. I agree that it looks impractical to write a test for this without a significant refactor.
Oh -- I don't agree with the use of the |
I see, yes I think in that case maybe we can skip adding tests for this change. Thanks again! |
Added! |
…116144) (cherry picked from commit 02ee475) Co-authored-by: Itamar Oren <[email protected]>
GH-116415 is a backport of this pull request to the 3.12 branch. |
…116144) (cherry picked from commit 02ee475) Co-authored-by: Itamar Oren <[email protected]>
GH-116416 is a backport of this pull request to the 3.11 branch. |