diff --git a/CHANGES/3450.bugfix b/CHANGES/3450.bugfix new file mode 100644 index 00000000000..6b82b4c0481 --- /dev/null +++ b/CHANGES/3450.bugfix @@ -0,0 +1 @@ +Started using `MultiLoopChildWatcher` when it's available under POSIX while setting up the test I/O loop. diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 502efb67a20..b9361827b66 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -241,6 +241,7 @@ Pawel Miech Pepe Osca Philipp A. Pieter van Beek +Qiao Han Rafael Viotti Raphael Bialon Raúl Cumplido diff --git a/aiohttp/test_utils.py b/aiohttp/test_utils.py index e8ebb6d4ed0..06155bae19f 100644 --- a/aiohttp/test_utils.py +++ b/aiohttp/test_utils.py @@ -490,7 +490,16 @@ def setup_test_loop( asyncio.set_event_loop(loop) if sys.platform != "win32" and not skip_watcher: policy = asyncio.get_event_loop_policy() - watcher = asyncio.SafeChildWatcher() + watcher: asyncio.AbstractChildWatcher + try: # Python >= 3.8 + # Refs: + # * https://github.com/pytest-dev/pytest-xdist/issues/620 + # * https://stackoverflow.com/a/58614689/595220 + # * https://bugs.python.org/issue35621 + # * https://github.com/python/cpython/pull/14344 + watcher = asyncio.MultiLoopChildWatcher() + except AttributeError: # Python < 3.8 + watcher = asyncio.SafeChildWatcher() watcher.attach_loop(loop) with contextlib.suppress(NotImplementedError): policy.set_child_watcher(watcher)