Skip to content

Commit 4cab2cd

Browse files
authored
bpo-31238: pydoc ServerThread.stop() now joins itself (#3151)
* bpo-31238: pydoc ServerThread.stop() now joins itself 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. * Add NEWS.d entry
1 parent 489d91c commit 4cab2cd

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
@@ -2297,6 +2297,10 @@ def ready(self, server):
22972297
def stop(self):
22982298
"""Stop the server and this thread nicely"""
22992299
self.docserver.quit = True
2300+
self.join()
2301+
# explicitly break a reference cycle: DocServer.callback
2302+
# has indirectly a reference to ServerThread.
2303+
self.docserver = None
23002304
self.serving = False
23012305
self.url = None
23022306

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)