Skip to content

Commit

Permalink
[PR #5862/7080a8bb backport][3.8] Use MultiLoopChildWatcher in test…
Browse files Browse the repository at this point in the history
…s where available (#5863)

Co-authored-by: Sviatoslav Sydorenko <[email protected]>
Co-authored-by: Han Qiao <[email protected]>
  • Loading branch information
3 people authored Jul 7, 2021
1 parent 420cc71 commit 68f0262
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/3450.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Started using `MultiLoopChildWatcher` when it's available under POSIX while setting up the test I/O loop.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ Pawel Miech
Pepe Osca
Philipp A.
Pieter van Beek
Qiao Han
Rafael Viotti
Raphael Bialon
Raúl Cumplido
Expand Down
11 changes: 10 additions & 1 deletion aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,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)
Expand Down

0 comments on commit 68f0262

Please sign in to comment.