-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: panic: close of closed channel #5939
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
Conversation
|
for |
|
The usage of |
bombsimon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| select { | ||
| case <-ctx.Done(): | ||
| return | ||
| default: | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be logically the same but when ctx.Done() is closed ctx.Err() will return a non nil error. Just a personal pref on what's easier to read I guess.
| select { | |
| case <-ctx.Done(): | |
| return | |
| default: | |
| } | |
| if ctx.Err() != nil { | |
| return | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this situation, for me, checking the error is confusing because we don't expect an error but a stop, and it will act like we are ignoring an error.
It's a personal pref too, but in this context, I prefer using Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go for it, either works. ✅
* build(deps): bump github.com/go-critic/go-critic from 0.12.0 to 0.13.0 (golangci#5579) * build(deps): bump mvdan.cc/unparam to HEAD (golangci#5584) * build(deps): bump github.com/timakin/bodyclose from ed6a65f985e3 to 1db5c5ca4d67 (golangci#5585) * docs: improve Docker example with cache reuse (golangci#5586) * docs: add a migration guide for VSCode integration (golangci#5587) * build(deps): bump github.com/ckaznocha/intrange from 0.3.0 to 0.3.1 (golangci#5589) * feat: add option stdin for fmt command (golangci#5588) * build(deps): bump github.com/daixiang0/gci from 0.13.5 to 0.13.6 (golangci#5592) * fix: funlen ignore-comments (golangci#5594) * docs: cleaning * chore: prepare release * docs: update GitHub Action assets (golangci#5595) * docs: fix displaying GoLand logo on a dark theme (golangci#5598) * fix: validate version before configuration (golangci#5599) * fix: copy golines settings during linter settings load (golangci#5607) * fix: forbidigo migration (golangci#5606) * docs: add example of the field version (golangci#5609) * chore: prepare release * docs: update GitHub Action assets (golangci#5611) Co-authored-by: Fernandez Ludovic <
I used a global cancellable
contextbecausecancelis concurrency safe (and so can be called several times).The background of the problem is the fact of having go routines inside go routines inside go routines.
I think I will rewrite this section at some point.
To reproduce, I replaced
Nextwith a non-existent methodFoo.git clone https://github.com/NVIDIA/aistore.git cd aistore git checkout 7730e4290Fixes #5938
Related to #5929, #5923