Skip to content

Commit

Permalink
feat: Use the REQUESTS_POOL_MAXSIZE environment variable to set the m…
Browse files Browse the repository at this point in the history
…aximum number of connections to save in the connection pool
  • Loading branch information
jpmckinney committed Jan 12, 2022
1 parent 8e109bf commit 74e90a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Expand Up @@ -4,6 +4,7 @@ Changelog
0.1.7 (Unreleased)
------------------

- Use the ``REQUESTS_POOL_MAXSIZE`` environment variable to set the maximum number of connections to save in the `connection pool <https://urllib3.readthedocs.io/en/latest/advanced-usage.html#customizing-pool-behavior>`__.
- Drop support for Python 3.6 (end-of-life 2021-12-23).

0.1.6 (2021-11-29)
Expand Down
6 changes: 6 additions & 0 deletions ocdsextensionregistry/util.py
Expand Up @@ -4,6 +4,7 @@
from urllib.parse import urlsplit
from zipfile import ZipFile

from requests.adapters import HTTPAdapter
from requests_cache import CachedSession

from .exceptions import UnknownLatestVersion
Expand All @@ -15,7 +16,12 @@

default_minor_version = '1.1'

# https://2.python-requests.org/projects/3/api/#requests.adapters.HTTPAdapter
# https://urllib3.readthedocs.io/en/latest/advanced-usage.html#customizing-pool-behavior
adapter = HTTPAdapter(pool_maxsize=os.getenv('REQUESTS_POOL_MAXSIZE', 10))
session = CachedSession(backend='memory')
session.mount('https://', adapter)
session.mount('http://', adapter)


def json_dump(data, io):
Expand Down

0 comments on commit 74e90a5

Please sign in to comment.