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

Always run functions given to Go()? #8

Open
horgh opened this issue May 6, 2021 · 1 comment
Open

Always run functions given to Go()? #8

horgh opened this issue May 6, 2021 · 1 comment

Comments

@horgh
Copy link

horgh commented May 6, 2021

Hi agai!. Sorry to be opening so many issues :-P.

I came across another interesting behaviour difference compared to golang.org/x/sync/errgroup: It's possible for functions given to Go() to never be run.

This can happen, I believe, if a worker goroutine encounters an error (such as a context cancellation) and then returns (in the goroutine in startG()). Then in Wait(), since our only condition to stop is waiting on the waitgroup, we end up setting qCh to nil and returning. This could leave messages in qCh that never get seen.

golang.org/x/sync/errgroup on the other hand will always run a goroutine given to Go().

It would be pretty racey to cause and I haven't reproduced it, but I encountered an issue with a service I have where it assumes a function must be run, even if it's going to error.

I'm not sure what the best thing to do is however. If there's been an error, should we bother trying to run any queued functions? I'm not sure. But perhaps so since it would be a difference compared to what golang.org/x/sync/errgroup does.

@neilotoole
Copy link
Owner

@horgh Apologies for the radio silence, it was a summer off open-source work.

I'm not sure what the best thing to do is however.

I'm not quite sure either. Between this and the previous issues you've raised, I wonder if the goal of "identical behavior to sync/errgroup" is achievable. Unfortunately I haven't been able to devote the time to look into those issues in detail (the package has worked well enough for the use cases I had, which are more trivial than yours). But if you've been able to make headway on those topics, I'd love to see a PR (even if partial).

Again, apologies for the delay in responding.

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

No branches or pull requests

2 participants