use requests.Session for connection reuse #28

Merged
merged 1 commit into from Jul 17, 2016

Conversation

Projects
None yet
2 participants
@beda42
Contributor

beda42 commented Jul 17, 2016

The current version opens a new connection for each API request even though the server supports HTTP keep-alive and thus many requests could be made using the same connection.
This patch uses requests.Session to allow connection reuse. This shaves something like 400 ms from each subsequent request because there is no need to open a new connection. For people doing many requests in short succession this can lead to significant speed up (about 2x the speed for my case of doing many host requests).

@achillean achillean merged commit 9df9c8d into achillean:master Jul 17, 2016

@achillean

This comment has been minimized.

Show comment
Hide comment
@achillean

achillean Jul 17, 2016

Owner

Thank you for the pull request! Nice change that should help w/ scripts doing many requests (ex. downloading data).

Owner

achillean commented Jul 17, 2016

Thank you for the pull request! Nice change that should help w/ scripts doing many requests (ex. downloading data).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment