-
Notifications
You must be signed in to change notification settings - Fork 18k
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
context: WithCancel should return a cancel function which can accept an error #34764
Comments
WithCancel can't be changed without breaking backwards compatibility. Likewise, we can't change CancelFunc. What exactly are you proposing? |
ref: #34761 |
Note that it's fairly trivial to write your own wrapper around |
That is exactly what an |
Great! Thanks for your help. |
Is there anything else to do for this issue? |
Sometimes, we run multiple go routines in a context, if one go routine fails due to an error, we
want to cancel the context and record the error in it. Such as a task has several workers, each worker works independently, if a worker fails , the task is supposed to fail and report the cause.
I want to cancel the context if a worker fails due to an error, and record the error in the context.
However, the CancelFunc returned by WithCancel can not accept an error. I think a new type of
cancel function is needed which user can pass an error into it and can be returned by WithCancel.
The text was updated successfully, but these errors were encountered: