Skip to content

Commit eb61a01

Browse files
author
Hynek Davídek
committed
Initialize pool manager with timeout
1 parent 8f5455e commit eb61a01

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+
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=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)