pond
pond copied to clipboard
Fail tasks before while they are queued
Hello @alitto
I'm in need of feature to cancel tasks forsefully from pond queue, and there are ways to do it outside of pond but this is the prefered one. I'll gladly implement it myself, so the question is are you willing to integrate it in your project or i should implement it via fork?
Hey @tynrol
As you point out, the best way to cancel a particular task at the moment is to pass a custom cancellable context to it directly in the function body, and cancel it from the outside, e.g.:
ctx, cancel := context.WithCancel(context.Background())
pool.Submit(func() {
select {
case <-ctx.Done():
fmt.Println("task canceled")
case <-taskCompleted:
}
return
})
cancel() // Cancel the task
I'd like to know more about your proposal, please share a code example here to discuss. The preferred way to send contributions is via a fork of this repo.