8000 gh-124309: Modernize the `staggered_race` implementation to support eager task factories by ZeroIntensity · Pull Request #124390 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-124309: Modernize the staggered_race implementation to support eager task factories #124390

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Deprecate the loop parameter.
  • Loading branch information
ZeroIntensity committed Sep 24, 2024
commit 69408894e5f86ecc29372dfcbead3c36f75c1a72
13 changes: 10 additions & 3 deletions Lib/asyncio/staggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
from . import tasks
from . import taskgroups


class _Done(Exception):
pass


async def staggered_race(coro_fns, delay):
async def staggered_race(coro_fns, delay, *, loop=None):
"""Run coroutines with staggered start times and take the first to finish.

This method takes an iterable of coroutine functions. The first one is
Expand Down Expand Up @@ -67,6 +65,15 @@ async def staggered_race(coro_fns, delay):
winner_index = None
exceptions = []

if loop is not None:
import warnings
warnings._deprecated(
'loop',
'the {name!r} parameter is deprecated and slated for removal in '
'Python {remove}; it does nothing since 3.14',
remove=(3, 16),
)

async def run_one_coro(this_index, coro_fn, this_failed):
try:
result = await coro_fn()
Expand Down
Loading
0