8000 gh-124309: Revert eager task factory fix to prevent breaking downstream by ZeroIntensity · Pull Request #124810 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-124309: Revert eager task factory fix to prevent breaking downstream #124810

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 2 commits into from
Oct 1, 2024
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
Next Next commit
Revert "GH-124639: add back loop param to staggered_race (#124700)"
This reverts commit e0a41a5.
  • Loading branch information
ZeroIntensity committed Sep 30, 2024
commit 6d50ee918451e51cae34c64af306a6f75a1d61fd
10 changes: 2 additions & 8 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 @@ -82,13 +82,7 @@ async def run_one_coro(this_index, coro_fn, this_failed):
raise _Done

try:
tg = taskgroups.TaskGroup()
# Intentionally override the loop in the TaskGroup to avoid
# using the running loop, preserving backwards compatibility
# TaskGroup only starts using `_loop` after `__aenter__`
# so overriding it here is safe.
tg._loop = loop
async with tg:
async with taskgroups.TaskGroup() as tg:
for this_index, coro_fn in enumerate(coro_fns):
this_failed = locks.Event()
exceptions.append(None)
Expand Down
19 changes: 0 additions & 19 deletions Lib/test/test_asyncio/test_staggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,6 @@ async def coro(index):
self.assertIsInstance(excs[0], ValueError)
self.assertIsNone(excs[1])

def test_loop_argument(self):
loop = asyncio.new_event_loop()
async def coro():
self.assertEqual(loop, asyncio.get_running_loop())
return 'coro'

async def main():
winner, index, excs = await staggered_race(
[coro],
delay=0.1,
loop=loop
)

self.assertEqual(winner, 'coro')
self.assertEqual(index, 0)

loop.run_until_complete(main())
loop.close()


if __name__ == "__main__":
unittest.main()
0