Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Wrap connections in an N minute timeout to ensure they get reaped correctly #1725

Merged
merged 6 commits into from
Dec 29, 2016

Conversation

erikjohnston
Copy link
Member

No description provided.


# 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)
Copy link
Member

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):
Copy link
Member

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):
Copy link
Member

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)
Copy link
Member

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()?

Copy link
Member Author

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
Copy link
Member

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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants