how to cancel a work pool? #324
Unanswered
plastikfan
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When you create a pool, since the api doesn't include a context, it is difficult to see how cancellation is supported in an ants worker pool.
A typical usage of the pool with func would be something like this (derived from one of the ants testcases):
But as I see it, there is a problem with this:
What if the pool needs to be cancelled part way through? The problem manifests itself by the fact that the client is performing a wait on the waitgroup, which could be a high number, so even if we could cancel somehow, the wait would need to be pre-empted to avoid waiting for the wait group counter to reach zero, but it won't.
I'm not sure how/if cancellation is supported so I would appreciate some enlightenment about this, thanks.
Beta Was this translation helpful? Give feedback.
All reactions