[Python-checkins] bpo-31238: pydoc ServerThread.stop() now joins itself (#3151)
Victor Stinner
webhook-mailer at python.org
Mon Aug 21 17:24:43 EDT 2017
https://github.com/python/cpython/commit/4cab2cd0c05fcda5fcb128c9eb230253fff88c21
commit: 4cab2cd0c05fcda5fcb128c9eb230253fff88c21
branch: master
author: Victor Stinner <victor.stinner at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-08-21T23:24:40+02:00
summary:
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
files:
A Misc/NEWS.d/next/Library/2017-08-21-12-31-53.bpo-31238.Gg0LRH.rst
M Lib/pydoc.py
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 376c4459fe6..5edc77005a8 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -2297,6 +2297,10 @@ def ready(self, server):
def stop(self):
"""Stop the server and this thread nicely"""
self.docserver.quit = True
+ self.join()
+ # explicitly break a reference cycle: DocServer.callback
+ # has indirectly a reference to ServerThread.
+ self.docserver = None
self.serving = False
self.url = None
diff --git a/Misc/NEWS.d/next/Library/2017-08-21-12-31-53.bpo-31238.Gg0LRH.rst b/Misc/NEWS.d/next/Library/2017-08-21-12-31-53.bpo-31238.Gg0LRH.rst
new file mode 100644
index 00000000000..3e1cd130100
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2017-08-21-12-31-53.bpo-31238.Gg0LRH.rst
@@ -0,0 +1,3 @@
+pydoc: the stop() method of the private ServerThread class now waits until
+DocServer.serve_until_quit() completes and then explicitly sets its
+docserver attribute to None to break a reference cycle.
More information about the Python-checkins
mailing list