10000 gh-128479: fix asyncio staggered race leaking tasks, and logging unhandled exception.append exception by graingert · Pull Request #128475 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128479: fix asyncio staggered race leaking tasks, and logging unhandled exception.append exception #128475

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
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
Apply suggestions from code review
  • Loading branch information
graingert authored Jan 4, 2025
commit 9fc105f0f4d25b9683eee1e14d95db26246726df
6 changes: 3 additions & 3 deletions Lib/asyncio/staggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def task_done(task):
and not on_completed_fut.done()
and not running_tasks
):
on_completed_fut.set_result(True)
on_completed_fut.set_result(None)

if task.cancelled():
return
Expand Down Expand Up @@ -110,7 +110,7 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
next_task = loop.create_task(run_one_coro(next_ok_to_start, this_failed))
running_tasks.add(next_task)
next_task.add_done_callback(task_done)
# next_task has been appended to running_tasks so next_task is ok to
# next_task has been appended to running_tasks so next_task is ok to
# start.
next_ok_to_start.set()
# Prepare place to put this coroutine's exceptions if not won
Expand Down Expand Up @@ -166,7 +166,7 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
if __debug__ and unhandled_exceptions:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably this should just always raise it, not sure why this was suppressed in the original code

# If run_one_coro raises an unhandled exception, it's probably a
# programming error, and I want to see it.
raise ExceptionGroup("multiple errors in staggered race", unhandled_exceptions)
raise ExceptionGroup("staggered race failed", unhandled_exceptions)
if propagate_cancellation_error is not None:
raise propagate_cancellation_error
return winner_result, winner_index, exceptions
Expand Down
Loading
0