Skip to content
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

Eat cancellation exceptions from WaitAsync in Parallel.ForEachAsync #66712

Merged
merged 1 commit into from
Mar 23, 2022

Conversation

stephentoub
Copy link
Member

We can safely ignore cancellation exceptions due to WaitAsync being canceled. They do not represent work that was started and interrupted, and we know exactly the source of the exception (as compared to if the exception emerged from either MoveNextAsync or the loop body).

Fixes #66695

We can safely ignore cancellation exceptions due to WaitAsync being canceled.  They do not represent work that was started and interrupted, and we know exactly the source of the exception (as compared to if the exception emerged from either MoveNextAsync or the loop body).
@ghost
Copy link

ghost commented Mar 16, 2022

Tagging subscribers to this area: @dotnet/area-system-threading-tasks
See info in area-owners.md if you want to be subscribed.

Issue Details

We can safely ignore cancellation exceptions due to WaitAsync being canceled. They do not represent work that was started and interrupted, and we know exactly the source of the exception (as compared to if the exception emerged from either MoveNextAsync or the loop body).

Fixes #66695

Author: stephentoub
Assignees: -
Labels:

area-System.Threading.Tasks

Milestone: 7.0.0

@stephentoub
Copy link
Member Author

@dotnet/area-system-threading-tasks, could someone help review this small change please? It basically just adds a try/catch block.

Copy link
Contributor

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@stephentoub stephentoub merged commit a5665da into dotnet:main Mar 23, 2022
@stephentoub stephentoub deleted the eatparallelcancel branch March 23, 2022 22:40
radekdoulik pushed a commit to radekdoulik/runtime that referenced this pull request Mar 30, 2022
…otnet#66712)

We can safely ignore cancellation exceptions due to WaitAsync being canceled.  They do not represent work that was started and interrupted, and we know exactly the source of the exception (as compared to if the exception emerged from either MoveNextAsync or the loop body).
@ghost ghost locked as resolved and limited conversation to collaborators Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Parallel.ForEachAsync propagates OperationCanceledException of unknown origin
2 participants