Skip to content

Update thread.ParallelizeWithCancel to thread.ParallelizeWithCancelOnFailure that no longer takes a context.CancelFunc #3246

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 1 commit into from
Aug 16, 2024

Conversation

bufdev
Copy link
Member

@bufdev bufdev commented Aug 16, 2024

thread.ParallelizeWithCancel would call a provided context.CancelFunc if any given job failed. However:

  • All we wanted to do was make sure a cancel was sent to ctx on any job failure.
  • Every time we called thread.ParallelizeWithCancel, we created the CancelFunc right before it:
// This is every call we made.
ctx, cancel := context.WithCancel(ctx)
defer cancel()
return thread.Parallelize(ctx, jobs, thread.ParallelizeWithCancel(cancel))

This was confusing and unnecessary - all we need to do is create a CancelFunc within Parallelize if we want this behavior.

This PR updates the option to do just this, along with a rename in line with this behavior.

…Failure that no longer takes a context.CancelFunc
Copy link
Contributor

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 16, 2024, 8:07 PM

@bufdev bufdev merged commit b029c1f into main Aug 16, 2024
13 checks passed
@bufdev bufdev deleted the parallelize-cancel-on-failure branch August 16, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants