-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-38356: Fix ThreadedChildWatcher thread leak in test_asyncio #16552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4a8395a
bfc0d6c
fbf7f0d
6bcf009
fe2b256
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1266,7 +1266,14 @@ def is_active(self): | |
return True | ||
|
||
def close(self): | ||
pass | ||
self._join_threads() | ||
|
||
def _join_threads(self): | ||
"""Internal: Join all non-daemon threads""" | ||
threads = [thread for thread in list(self._threads.values()) | ||
if thread.is_alive() and not thread.daemon] | ||
for thread in threads: | ||
thread.join() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to remove the thread from self._threads as soon as a thread complete?
Would it be possible to log a warning if a thread runs longer than timeout seconds? Or even exit silently if the timoeut is exceeded? Maybe we should also modify add_child_handler() to raise an exception if it's called after close() has been called? For example, add a _closed attribute? It would prevent to spawn new threads while we wait for existing threads. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah sure, I would have no issue with adding something like this. I'm not 100% sure that we have to remove the threads that aren't alive from What exactly does removing the threads from
This should be possible by running Unless by "exit silently" you were referring to
Yeah this would be a fairly straightforward change and I agree with it. A |
||
|
||
def __enter__(self): | ||
return self | ||
|
Uh oh!
There was an error while loading. Please reload this page.