Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 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 likethread.serving will always be set beforethread.docserver. It's set in thethread.ready() callback, which is called inDocServer.server_activate, which is called fromTCPServer.__init__, so it will definitely happen -- barring an error occurring instead -- before theDocServer(...) 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! |
GH-116415 is a backport of this pull request to the3.12 branch. |
GH-116416 is a backport of this pull request to the3.11 branch. |
Uh oh!
There was an error while loading.Please reload this page.