Skip to content

Commit 0df32d5

Browse files
committed
1 parent 1ec360f commit 0df32d5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

aiohttp/test_utils.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,16 @@ def setup_test_loop(
506506
asyncio.set_event_loop(loop)
507507
if sys.platform != "win32" and not skip_watcher:
508508
policy = asyncio.get_event_loop_policy()
509-
watcher = asyncio.SafeChildWatcher()
509+
watcher: asyncio.AbstractChildWatcher
510+
try: # Python >= 3.8
511+
# Refs:
512+
# * https://github.com/pytest-dev/pytest-xdist/issues/620
513+
# * https://stackoverflow.com/a/58614689/595220
514+
# * https://bugs.python.org/issue35621
515+
# * https://github.com/python/cpython/pull/14344
516+
watcher = asyncio.ThreadedChildWatcher()
517+
except AttributeError: # Python < 3.8
518+
watcher = asyncio.SafeChildWatcher()
510519
watcher.attach_loop(loop)
511520
with contextlib.suppress(NotImplementedError):
512521
policy.set_child_watcher(watcher)

0 commit comments

Comments
 (0)