Skip to content

Commit e7d51f0

Browse files
hynekdavHynek Davídekjustinpolygon
authored
Initialize pool manager with timeout (#977)
* Initialize pool manager with timeout * chore: expose self.timeout on BaseClient + minor cleanup --------- Co-authored-by: Hynek Davídek <hynek.davidek@quantlane.com> Co-authored-by: justinpolygon <123573436+justinpolygon@users.noreply.github.com>
1 parent a6497de commit e7d51f0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

massive/rest/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def __init__(
6868
backoff_factor=0.1, # [0.0s, 0.2s, 0.4s, 0.8s, 1.6s, ...]
6969
)
7070

71+
# https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html#urllib3.util.Timeout
72+
self.timeout = urllib3.Timeout(connect=connect_timeout, read=read_timeout)
73+
7174
# https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html
7275
# https://urllib3.readthedocs.io/en/stable/reference/urllib3.connectionpool.html#urllib3.HTTPConnectionPool
7376
self.client = urllib3.PoolManager(
@@ -76,10 +79,9 @@ def __init__(
7679
ca_certs=certifi.where(),
7780
cert_reqs="CERT_REQUIRED",
7881
retries=retry_strategy, # use the customized Retry instance
82+
timeout=self.timeout, # set timeout for each request
7983
)
8084

81-
self.timeout = urllib3.Timeout(connect=connect_timeout, read=read_timeout)
82-
8385
if verbose:
8486
logger.setLevel(logging.DEBUG)
8587
self.trace = trace

0 commit comments

Comments
 (0)