From 8456fddf2490403d16bf6fcf9e3bf0c41a295511 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria Date: Thu, 22 Jun 2023 15:11:45 +0200 Subject: [PATCH] Set version 5.5.0 --- gnosis/eth/clients/etherscan_client.py | 2 +- gnosis/eth/clients/sourcify.py | 2 +- gnosis/eth/ethereum_client.py | 2 +- gnosis/protocol/gnosis_protocol_api.py | 2 +- gnosis/safe/api/base_api.py | 19 ++++++++++++++++++- setup.cfg | 2 +- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gnosis/eth/clients/etherscan_client.py b/gnosis/eth/clients/etherscan_client.py index 56f5d1804..d854f22b7 100644 --- a/gnosis/eth/clients/etherscan_client.py +++ b/gnosis/eth/clients/etherscan_client.py @@ -97,7 +97,7 @@ def _prepare_http_session(self) -> requests.Session: """ Prepare http session with custom pooling. See: https://urllib3.readthedocs.io/en/stable/advanced-usage.html - https://2.python-requests.org/en/latest/api/#requests.adapters.HTTPAdapter + https://docs.python-requests.org/en/v1.2.3/api/#requests.adapters.HTTPAdapter https://web3py.readthedocs.io/en/stable/providers.html#httpprovider """ session = requests.Session() diff --git a/gnosis/eth/clients/sourcify.py b/gnosis/eth/clients/sourcify.py index 9f2538404..bba39a0dd 100644 --- a/gnosis/eth/clients/sourcify.py +++ b/gnosis/eth/clients/sourcify.py @@ -35,7 +35,7 @@ def _prepare_http_session(self) -> requests.Session: """ Prepare http session with custom pooling. See: https://urllib3.readthedocs.io/en/stable/advanced-usage.html - https://2.python-requests.org/en/latest/api/#requests.adapters.HTTPAdapter + https://docs.python-requests.org/en/v1.2.3/api/#requests.adapters.HTTPAdapter https://web3py.readthedocs.io/en/stable/providers.html#httpprovider """ session = requests.Session() diff --git a/gnosis/eth/ethereum_client.py b/gnosis/eth/ethereum_client.py index 578914b3b..68dd6f556 100644 --- a/gnosis/eth/ethereum_client.py +++ b/gnosis/eth/ethereum_client.py @@ -1211,7 +1211,7 @@ def _prepare_http_session(self, retry_count: int) -> requests.Session: """ Prepare http session with custom pooling. See: https://urllib3.readthedocs.io/en/stable/advanced-usage.html - https://2.python-requests.org/en/latest/api/#requests.adapters.HTTPAdapter + https://docs.python-requests.org/en/v1.2.3/api/#requests.adapters.HTTPAdapter https://web3py.readthedocs.io/en/stable/providers.html#httpprovider """ session = requests.Session() diff --git a/gnosis/protocol/gnosis_protocol_api.py b/gnosis/protocol/gnosis_protocol_api.py index 024887cf6..93134155a 100644 --- a/gnosis/protocol/gnosis_protocol_api.py +++ b/gnosis/protocol/gnosis_protocol_api.py @@ -71,7 +71,7 @@ def _prepare_http_session(self) -> requests.Session: """ Prepare http session with custom pooling. See: https://urllib3.readthedocs.io/en/stable/advanced-usage.html - https://2.python-requests.org/en/latest/api/#requests.adapters.HTTPAdapter + https://docs.python-requests.org/en/v1.2.3/api/#requests.adapters.HTTPAdapter https://web3py.readthedocs.io/en/stable/providers.html#httpprovider """ session = requests.Session() diff --git a/gnosis/safe/api/base_api.py b/gnosis/safe/api/base_api.py index d845e68b1..00909689a 100644 --- a/gnosis/safe/api/base_api.py +++ b/gnosis/safe/api/base_api.py @@ -36,9 +36,26 @@ def __init__( self.base_url = base_url or self.URL_BY_NETWORK.get(network) if not self.base_url: raise EthereumNetworkNotSupported(network) - self.http_session = requests.Session() + self.http_session = self._prepare_http_session() self.request_timeout = request_timeout + def _prepare_http_session(self) -> requests.Session: + """ + Prepare http session with custom pooling. See: + https://urllib3.readthedocs.io/en/stable/advanced-usage.html + https://docs.python-requests.org/en/v1.2.3/api/#requests.adapters.HTTPAdapter + https://web3py.readthedocs.io/en/stable/providers.html#httpprovider + """ + session = requests.Session() + adapter = requests.adapters.HTTPAdapter( + pool_connections=10, # Doing all the connections to the same url + pool_maxsize=100, # Number of concurrent connections + pool_block=False, + ) + session.mount("http://", adapter) + session.mount("https://", adapter) + return session + @classmethod def from_ethereum_client(cls, ethereum_client: EthereumClient) -> "SafeBaseAPI": ethereum_network = ethereum_client.get_network() diff --git a/setup.cfg b/setup.cfg index 769f5405e..c70299489 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = safe-eth-py -version = 5.4.3 +version = 5.5.0 description = Safe Ecosystem Foundation utilities for Ethereum projects long_description = file: README.rst long_description_content_type = text/x-rst; charset=UTF-8