You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pydoc: ServerThread.stop() leaves a dangling thread #75421
When using #3138 I see that test_pydoc leaves a dangling thread. The bug comes from test_server() which uses pydoc ServerThread.
ServerThread.stop() and test_pydoc don't join the thread. Moreover, ServerThread.docserver has a reference cycle through the DocServer.callback attribute.
Attached PR modifies ServerThread.stop() to join itself (the thread), to wait until the HTTP server completes, and then explicitly break the reference cycle.
With the PR, pydoc may hang if a bad HTTP client. So another option is to only modify test_pydoc to join() + break the ref cycle.
I left Python 2.7 and 3.6 unchanged to focus on fixing dangling threads and other similar bugs in the master branch first. I will see later if we really need to backport the fix to stable branches. In the meanwhile, I close the issue.
Activity
vstinner commentedon Aug 18, 2017
When using #3138 I see that test_pydoc leaves a dangling thread. The bug comes from test_server() which uses pydoc ServerThread.
ServerThread.stop() and test_pydoc don't join the thread. Moreover, ServerThread.docserver has a reference cycle through the DocServer.callback attribute.
Attached PR modifies ServerThread.stop() to join itself (the thread), to wait until the HTTP server completes, and then explicitly break the reference cycle.
With the PR, pydoc may hang if a bad HTTP client. So another option is to only modify test_pydoc to join() + break the ref cycle.
vstinner commentedon Aug 18, 2017
This issue is similar to bpo-31151: socketserver ForkingMixIn.server_close() leaks zombie processes.
vstinner commentedon Aug 21, 2017
New changeset 4cab2cd by Victor Stinner in branch 'master':
bpo-31238: pydoc ServerThread.stop() now joins itself (bpo-3151)
4cab2cd
vstinner commentedon Aug 22, 2017
I left Python 2.7 and 3.6 unchanged to focus on fixing dangling threads and other similar bugs in the master branch first. I will see later if we really need to backport the fix to stable branches. In the meanwhile, I close the issue.
vstinner commentedon Jun 1, 2018
New changeset f329743 by Victor Stinner in branch '3.6':
bpo-31238: pydoc ServerThread.stop() now joins itself (GH-3151) (GH-7324)
f329743