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

Connection Pooling #51

Merged
merged 6 commits into from Apr 19, 2018
Merged

Connection Pooling #51

merged 6 commits into from Apr 19, 2018

Conversation

danpalmer
Copy link
Contributor

This adds connection pooling via requests.Session to feeds and webhooks.

@@ -20,6 +21,11 @@ class FeedNotFetched(Exception):
pass


@functools.lru_cache()
def _get_feed_session():
return requests.Session()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't thread-safe: I think this should be thread-local.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coveralls
Copy link

coveralls commented Apr 19, 2018

Coverage Status

Coverage increased (+0.01%) to 98.905% when pulling 489b963 on connection-pooling into 3b76874 on master.

@@ -20,6 +21,11 @@ class FeedNotFetched(Exception):
pass


@functools.lru_cache()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an explicit maxsize would be nice here, just saves a google to figure out what the connection pool size is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to a thread local anyway, but unfortunately this probably wouldn't work as there's another layer of indirection within requests to the actual connection pool. There doesn't seem to be an easy way to expose the actual connection pool parameters here.

Copy link

@tomokas tomokas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! A comment about requests.Session using urrlib3's underlying connection pool would be great, as I wasn't aware of that!

@danpalmer danpalmer merged commit 54ce7e0 into master Apr 19, 2018
@danpalmer danpalmer deleted the connection-pooling branch April 19, 2018 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants