From 6e32c5391c5e03723d5d9cf286ac7779eae3c81e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 19 Aug 2017 01:44:00 +0200 Subject: [PATCH 1/2] 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. --- Lib/pydoc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 376c4459fe6b00e..5edc77005a87140 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 From d080a8bb55bb8b153945a4a3c57077aa30f0a7e7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 21 Aug 2017 12:31:59 +0200 Subject: [PATCH 2/2] Add NEWS.d entry --- .../next/Library/2017-08-21-12-31-53.bpo-31238.Gg0LRH.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2017-08-21-12-31-53.bpo-31238.Gg0LRH.rst 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 000000000000000..3e1cd130100376d --- /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.