-
Notifications
You must be signed in to change notification settings - Fork 158
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 pool_recycle keyword argument to Pool. #366
Conversation
aiopg/pool.py
Outdated
|
||
# Close connections that have lived longer than the recycle limit. | ||
if conn in self._free_timestamps: | ||
now = datetime.datetime.now() |
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.
Use loop.time()
instead
aiopg/pool.py
Outdated
self._conn_kwargs = kwargs | ||
self._acquiring = 0 | ||
self._free = collections.deque(maxlen=maxsize or None) | ||
self._free_timestamps = {} |
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 suggest storing timestamp into connection 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.
I was thinking about that, but Connection
doesn't know whether it's free or not at the moment, that I can tell. You'd be happy with an additional attribute which only gets updated through the pool?
I was going to add a free
method to Connection to handle updating the time
Codecov Report
@@ Coverage Diff @@
## master #366 +/- ##
==========================================
+ Coverage 93.49% 93.54% +0.05%
==========================================
Files 23 23
Lines 3550 3578 +28
Branches 205 208 +3
==========================================
+ Hits 3319 3347 +28
Misses 186 186
Partials 45 45
Continue to review full report at Codecov.
|
Just to note, I've made changes according to the comments/requested changes, though I'm not sure if this is 100% what you meant slash if there are other places or concerns that I've missed which could get the connection out of sync with the pool |
closing because #373 seems to do the same thing better! |
Add a pool_recycle option similar to the optional available in sqlalchemy