gh-116143: Fix race condition in pydoc _start_server#116144
gh-116143: Fix race condition in pydoc _start_server#116144carljm merged 3 commits intopython:mainfrom
Conversation
Jason-Y-Z
left a comment
There was a problem hiding this comment.
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 |
carljm
left a comment
There was a problem hiding this comment.
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. |
Uh oh!
There was an error while loading. Please reload this page.