-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Wrap connections in an N minute timeout to ensure they get reaped correctly #1725
Conversation
|
||
# Time this connection out if we haven't send a request in the last | ||
# N minutes | ||
reactor.callLater(3 * 60, self._time_things_out_maybe) |
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 is it 3 mins here, but 2 mins in the _time_things_out_maybe above?
return _WrappingEndointFac(transport_endpoint(reactor, domain, port, **endpoint_kw_args)) | ||
|
||
|
||
class _WrappingEndointFac(object): |
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.
s/Endoint/Endpoint/ probably ;)
@@ -61,6 +61,11 @@ | |||
MAX_SHORT_RETRIES = 3 | |||
|
|||
|
|||
def test(conn): |
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.
hm, is this meant to be here?
reactor.callLater(3 * 60, self._time_things_out_maybe) | ||
return res | ||
|
||
d.addCallback(update_request_time) |
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 we do this by both a callback and a reactor.callLater()?
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.
We schedule a timeout in 3 minutes both before we send the request, and after we received the response.
|
||
|
||
class _WrappedConnection(object): | ||
"""Wraps a connection and calls abort on it if it hasn't seen any actio |
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.
missing "n" in "action". Also, the comment says 5 minutes, but the code says 3 minutes?
The abort() method calls loseConnection() which tries to shutdown the TLS connection cleanly. We now call abortConnection() directly which should promptly close both the TLS connection and the underlying TCP connection. I also added some TODO markers to consider cancelling the old previous timeout rather than checking time.time(). But given how urgently we want to get this code released I'd rather leave the existing code with the duplicate timeouts and the time.time() check.
No description provided.