Skip to content

Commit f329743

Browse files
authored
bpo-31238: pydoc ServerThread.stop() now joins itself (GH-3151) (GH-7324)
ServerThread.stop() now joins itself to wait until DocServer.serve_until_quit() completes and then explicitly sets its docserver attribute to None to break a reference cycle. (cherry picked from commit 4cab2cd)
1 parent 1381bfe commit f329743

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/pydoc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,10 @@ def ready(self, server):
22732273
def stop(self):
22742274
"""Stop the server and this thread nicely"""
22752275
self.docserver.quit = True
2276+
self.join()
2277+
# explicitly break a reference cycle: DocServer.callback
2278+
# has indirectly a reference to ServerThread.
2279+
self.docserver = None
22762280
self.serving = False
22772281
self.url = None
22782282

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pydoc: the stop() method of the private ServerThread class now waits until
2+
DocServer.serve_until_quit() completes and then explicitly sets its
3+
docserver attribute to None to break a reference cycle.

0 commit comments

Comments
 (0)