]> granicus.if.org Git - python/commitdiff
bpo-31238: pydoc ServerThread.stop() now joins itself (GH-3151) (GH-7324)
authorVictor Stinner <vstinner@redhat.com>
Fri, 1 Jun 2018 17:39:16 +0000 (19:39 +0200)
committerGitHub <noreply@github.com>
Fri, 1 Jun 2018 17:39:16 +0000 (19:39 +0200)
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 4cab2cd0c05fcda5fcb128c9eb230253fff88c21)

Lib/pydoc.py
Misc/NEWS.d/next/Library/2017-08-21-12-31-53.bpo-31238.Gg0LRH.rst [new file with mode: 0644]

index 40ee76044089437e72673da0072efcae9bd2abdd..8c707540030b297aa06ce32df3eb56b8d2e0bf9d 100644 (file)
@@ -2273,6 +2273,10 @@ def _start_server(urlhandler, port):
         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 (file)
index 0000000..3e1cd13
--- /dev/null
@@ -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.