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

Disconnect expired clients on release #37

Merged
merged 2 commits into from
Nov 1, 2016

Conversation

cshoe
Copy link
Contributor

@cshoe cshoe commented Oct 26, 2016

After moving an app to use Tornadis, we started seeing connections leak.
We were using a pool of a limited size with a connection timeout. Since
the time deltas on connection state changes are calculated in
seconds, we tracked the connection leak down to
ClientPool.release_client. We found it possible for a client's
connection to expire while the client is in use most likely due to
rounding to whole seconds when calculating a client's freshness.
The client is never appended back to the pool allowing it to be
disconnected
here.

This change checks if the client is still connected if it's not placed
back into the pool and disconnects it.

After moving an app to use Tornadis, we started seeing connections leak.
We were using a pool of a limited size with a connection timeout. Since
the time delats are on connection state changes are calculated in
seconds, we tracked the connection leak down to
``ClientPool.release_client``. We found it possible for a client's
connection to expire while the client is in use most likely due to
rounding to whole seconds when calcuating a client's freshness. Since
the client is never appended back to the pool allowing it to be
disconnected
[here](https://github.com/thefab/tornadis/blob/master/tornadis/pool.py#L62).

This change checks if the client is still connected if it's not placed
back into the pool and disconnects it.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 89.708% when pulling 366ff26 on cshoe:connection-leaking-fix into 0fcfa52 on thefab:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 90.125% when pulling 9158393 on cshoe:connection-leaking-fix into 0fcfa52 on thefab:master.

@q
Copy link

q commented Nov 1, 2016

👍 need this.

@thefab thefab merged commit 91c4dab into thefab:master Nov 1, 2016
@thefab
Copy link
Owner

thefab commented Nov 1, 2016

just great !!! many thanks !!!

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.

None yet

4 participants