-
-
Notifications
You must be signed in to change notification settings - Fork 2
make sure stream exists before flushing #13
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
| if stream = @stream | ||
| if @stream | ||
| @stream.close | ||
| @stream = nil | ||
| stream.close |
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.
The pattern here is deliberate to set @stream to nil before calling #close which may, in theory, be a schedule point.
| # Write a message to the connection stream. | ||
| # | ||
| # @parameter message [Hash] The message to write. | ||
| def write(**message) |
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.
If we are going to do this, I think it's better that we are explicit rather than just silently failing the write, e.g. raise IOError
| def write(**message) | |
| def write(**message) | |
| raise IOError, "Connection closed!" if @stream.nil? |
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.
(Then, we should probably have the caller deal with this exception gracefully).
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.
yup - good idea 👍
It looks like Connection#call and Connection#dispatch already gracefully handles the IOError
98277d3 to
a550afe
Compare
|
Thanks! |
It is possible for
@streamto benilduring@stream.write.Types of Changes
Contribution