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

docker task manager: dont send to closed channels #2461

Merged
merged 1 commit into from
May 28, 2020

Conversation

sparrc
Copy link
Contributor

@sparrc sparrc commented May 27, 2020

Summary

Go channels do not need to be closed as a cleanup procedure. In fact, channels that are used to send data to will panic if they are closed and data is attempted to be sent (as we do in this case).

The only reason to close a channel in Go is to signal that it is closed to receivers of the channel. In the case of these channels we are not waiting on a closed channel signal.

see https://groups.google.com/forum/#!msg/golang-nuts/pZwdYRGxCIk/qpbHxRRPJdUJ

This change also uses a select statement when sending data on channels, to make sure that it doesn't hang when the manager's context has been cancelled.

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sparrc sparrc added this to the 1.41.0 milestone May 27, 2020
@sparrc sparrc changed the title [WIP] docker task manager: dont hang on closed channels docker task manager: dont hang on closed channels May 27, 2020
@sparrc sparrc changed the title docker task manager: dont hang on closed channels docker task manager: dont send to closed channels May 27, 2020
@sparrc sparrc merged commit 767c32f into aws:dev May 28, 2020
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

Successfully merging this pull request may close these issues.

4 participants