diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-03-06 14:58:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-06 14:58:02 (GMT) |
commit | 2528e46470162dd12a625ccb5dfe35fb7bcac1d3 (patch) | |
tree | a3516f7100ea578406ada5c212503051bc87fbb5 /Lib | |
parent | 5c69f60ae1859e53f858e65636d1c6d83873a963 (diff) | |
download | cpython-2528e46470162dd12a625ccb5dfe35fb7bcac1d3.zip cpython-2528e46470162dd12a625ccb5dfe35fb7bcac1d3.tar.gz cpython-2528e46470162dd12a625ccb5dfe35fb7bcac1d3.tar.bz2 |
[3.12] gh-116143: Fix race condition in pydoc _start_server (GH-116144) (#116415)
gh-116143: Fix race condition in pydoc _start_server (GH-116144)
(cherry picked from commit 02ee475ee3ce9468d44758df2cd79df9f0926303)
Co-authored-by: Itamar Oren <itamarost@gmail.com>
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/pydoc.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index bf855b4..9a88123 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -2493,6 +2493,7 @@ def _start_server(urlhandler, hostname, port): threading.Thread.__init__(self) self.serving = False self.error = None + self.docserver = None def run(self): """Start the server.""" @@ -2525,9 +2526,9 @@ def _start_server(urlhandler, hostname, port): thread = ServerThread(urlhandler, hostname, port) thread.start() - # Wait until thread.serving is True to make sure we are - # really up before returning. - while not thread.error and not thread.serving: + # Wait until thread.serving is True and thread.docserver is set + # to make sure we are really up before returning. + while not thread.error and not (thread.serving and thread.docserver): time.sleep(.01) return thread |