summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorItamar Oren <itamarost@gmail.com>2024-03-06 14:39:51 (GMT)
committerGitHub <noreply@github.com>2024-03-06 14:39:51 (GMT)
commit02ee475ee3ce9468d44758df2cd79df9f0926303 (patch)
tree9c9796548bd70adb7e85f8ab9047575e3e9f05a7 /Lib/pydoc.py
parente800265aa1f3451855a2fc14fbafc4d89392e35c (diff)
downloadcpython-02ee475ee3ce9468d44758df2cd79df9f0926303.zip
cpython-02ee475ee3ce9468d44758df2cd79df9f0926303.tar.gz
cpython-02ee475ee3ce9468d44758df2cd79df9f0926303.tar.bz2
gh-116143: Fix race condition in pydoc _start_server (#116144)
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 407c020..08fd7ab 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -2504,6 +2504,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."""
@@ -2536,9 +2537,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