diff options
| author | Victor Stinner <vstinner@redhat.com> | 2018-06-01 19:39:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-01 19:39:16 +0200 |
| commit | f3297433e309e9591eaa3f36e1d7887e9d0620d7 (patch) | |
| tree | 70413b2067b600000b89cc9232941eb9aa0cb178 | |
| parent | 1381bfe9776e64fed45935efbe42a7ee8298bd44 (diff) | |
| download | cpython-git-f3297433e309e9591eaa3f36e1d7887e9d0620d7.tar.gz | |
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 4cab2cd0c05fcda5fcb128c9eb230253fff88c21)
| -rw-r--r-- | Lib/pydoc.py | 4 | ||||
| -rw-r--r-- | Misc/NEWS.d/next/Library/2017-08-21-12-31-53.bpo-31238.Gg0LRH.rst | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 40ee760440..8c70754003 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -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 index 0000000000..3e1cd13010 --- /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. |
