polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
240 stars 114 forks source link

Reuse TCP connection for HTTP requests #195

Closed nathanwhit closed 2 years ago

nathanwhit commented 2 years ago

Currently, when making an HTTP request we use the requests.request method. This creates a new TCP connection for each request, and can lead to port exhaustion if you're performing many requests.

This PR adds a persistent Session for HTTP requests so that TCP connections are reused when possible. This avoids port exhaustion and improves performance for HTTP requests.

Fixes #18.

arjanz commented 2 years ago

Hi Nathan, I tested it and indeed fixes that problem. It's been on the backlog and off the radar for a while, so thanks for your PR! It will be included in next release