aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/asyncio/unix_events.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-10-27 15:44:12 -0700
committerGitHub <noreply@github.com>2023-10-27 15:44:12 -0700
commitc3bb10c9303503e7b55a7bdf9acfa6b3bcb699c6 (patch)
treea397c4aa0cf90638f08cc987f8e5a5f3aa1f39d3 /Lib/asyncio/unix_events.py
parent1c9a0c40794f0cb3234533d5e83234e7dce4ccd4 (diff)
downloadcpython-c3bb10c9303503e7b55a7bdf9acfa6b3bcb699c6.tar.gz
cpython-c3bb10c9303503e7b55a7bdf9acfa6b3bcb699c6.zip
gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (#110884)
- `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything. - Threads created by that class are now named `asyncio-waitpid-NNN`. - `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
Diffstat (limited to 'Lib/asyncio/unix_events.py')
-rw-r--r--Lib/asyncio/unix_events.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 809f29eecba..c9441918ecf 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -1371,14 +1371,7 @@ class ThreadedChildWatcher(AbstractChildWatcher):
return True
def close(self):
- 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()
+ pass
def __enter__(self):
return self
@@ -1397,7 +1390,7 @@ class ThreadedChildWatcher(AbstractChildWatcher):
def add_child_handler(self, pid, callback, *args):
loop = events.get_running_loop()
thread = threading.Thread(target=self._do_waitpid,
- name=f"waitpid-{next(self._pid_counter)}",
+ name=f"asyncio-waitpid-{next(self._pid_counter)}",
args=(loop, pid, callback, args),
daemon=True)
self._threads[pid] = thread