Skip to content

Commit

Permalink
Use ThreadedChildWatcher in tests where available
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Jan 25, 2021
1 parent 2aea4c0 commit 7b7a324
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,15 @@ 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()
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.ThreadedChildWatcher()
except AttributeError: # Python < 3.8
watcher = asyncio.SafeChildWatcher()
watcher.attach_loop(loop)
with contextlib.suppress(NotImplementedError):
policy.set_child_watcher(watcher)
Expand Down

0 comments on commit 7b7a324

Please sign in to comment.