-
Notifications
You must be signed in to change notification settings - Fork 321
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
Add an extra set of state tracking for Timeout.timeout edge cases #194
Conversation
@@ -98,6 +103,11 @@ def verify_connection!(uri) | |||
# lazily load the body as long as possible, and this mimics prior functionality. | |||
elsif @connection && (!@connection.keep_alive? || @connection.expired?) | |||
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.
Why do you add this extra line? :D
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.
I mean, can you try to avoid it? :D
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.
I find it makes it harder to read personally, but I don't really care either way.
Seems ugly but so does Timeout 😜 In absence of a fully asynchronous timeout scheme this seems ok to me. |
Yea it's not great unfortunately but such is life :( |
@@ -93,11 +98,14 @@ def close | |||
def verify_connection!(uri) | |||
if default_options.persistent? && base_host(uri) != default_options.persistent | |||
fail StateError, "Persistence is enabled for #{default_options.persistent}, but we got #{base_host(uri)}" | |||
|
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.
Thanks! 🙇
Add an extra set of state tracking for Timeout.timeout edge cases
Thoughts? This isn't strictly necessary, as the chance of this happening is very very small. It is still a chance though.
Normally,
Timeout.timeout
raises an exception and kills the block and everything is handy dandy. In rare situations, it will raise and then kill execution while therescue
block executes (see mperham/connection_pool#67 for more info).This adds an extra layer of protection, where if we run into that, we reset the connection anyway.