8000 GH-98388: Add tests for happy eyeballs and its internal workings by twisteroidambassador · Pull Request #98389 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-98388: Add tests for happy eyeballs and its internal workings #98389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Replace wait_for with wait.
This solution is compatible with all Python versions, and should pass all tests.
  • Loading branch information
twisteroidambassador committed Oct 19, 2022
commit 513f7f911690bbd704de0168564d83cd8c5fadd9
13 changes: 5 additions & 8 deletions Lib/asyncio/staggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

__all__ = 'staggered_race',

import contextlib
import typing

from . import events
from . import exceptions as exceptions_mod
from . import locks
from . import tasks

Expand Down Expand Up @@ -83,12 +81,11 @@ async def run_one_coro(
previous_failed: typing.Optional[locks.Event]) -> None:
# Wait for the previous task to finish, or for delay seconds
if previous_failed is not None:
with contextlib.suppress(exceptions_mod.TimeoutError):
# Use asyncio.wait_for() instead of asyncio.wait() here, so
# that if we get cancelled at this point, Event.wait() is also
# cancelled, otherwise there will be a "Task destroyed but it is
# pending" later.
await tasks.wait_for(previous_failed.wait(), delay)
wait_task = tasks.create_task(previous_failed.wait())
try:
await tasks.wait((wait_task,), timeout=delay)
finally:
wait_task.cancel()
# Get the next coroutine to run
try:
this_index, coro_fn = next(enum_coro_fns)
Expand Down
0