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
Show file tree
Hide file tree
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
code review
  • Loading branch information
kumaraditya303 committed Sep 26, 2024
commit 3fbbedb0ad64eeba7284d1244158b892497d55c8
11 changes: 1 addition & 10 deletions Lib/asyncio/staggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class _Done(Exception):
pass

async def staggered_race(coro_fns, delay, *, loop=None):
async def staggered_race(coro_fns, delay):
"""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 @@ -65,15 +65,6 @@ async def staggered_race(coro_fns, delay, *, loop=None):
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 is ignored since 3.14',
remove=(3, 16),
)

async def run_one_coro(this_index, coro_fn, this_failed):
try:
result = await coro_fn()
Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_asyncio/test_eager_task_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ async def run():

self.run_coro(run())

# See GH-124309 for both of these
def test_staggered_race_with_eager_tasks(self):
# See https://github.com/python/cpython/issues/124309

async def fail():
await asyncio.sleep(0) # Dummy coroutine
await asyncio.sleep(0)
raise ValueError("no good")

async def run():
Expand All @@ -237,6 +238,7 @@ async def run():
self.run_coro(run())

def test_staggered_race_with_eager_tasks_no_delay(self):
# See https://github.com/python/cpython/issues/124309
async def fail():
raise ValueError("no good")

Expand Down
0