mirror of
https://github.com/python/cpython.git
synced 2025-08-21 09:21:18 +00:00
[3.12] gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (GH-110884) (#111412)
- `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`.
(cherry picked from commit c3bb10c930
)
Co-authored-by: Guido van Rossum <guido@python.org>
This commit is contained in:
parent
754fda88d1
commit
2398036eea
2 changed files with 10 additions and 12 deletions
|
@ -547,6 +547,7 @@ class TestCase(unittest.TestCase):
|
|||
else:
|
||||
loop._default_executor.shutdown(wait=True)
|
||||
loop.close()
|
||||
|
||||
policy = support.maybe_get_event_loop_policy()
|
||||
if policy is not None:
|
||||
try:
|
||||
|
@ -558,9 +559,13 @@ class TestCase(unittest.TestCase):
|
|||
pass
|
||||
else:
|
||||
if isinstance(watcher, asyncio.ThreadedChildWatcher):
|
||||
threads = list(watcher._threads.values())
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
# Wait for subprocess to finish, but not forever
|
||||
for thread in list(watcher._threads.values()):
|
||||
thread.join(timeout=support.SHORT_TIMEOUT)
|
||||
if thread.is_alive():
|
||||
raise RuntimeError(f"thread {thread} still alive: "
|
||||
"subprocess still running")
|
||||
|
||||
|
||||
def set_event_loop(self, loop, *, cleanup=True):
|
||||
if loop is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue