Skip to content

Commit 5e36d0f

Browse files
committed
http: increase default read timeout; make configurable
1 parent 3ae25f9 commit 5e36d0f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

planet/http.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@
5050
MAX_RETRIES = 5
5151
MAX_RETRY_BACKOFF = 64 # seconds
5252

53-
# For how these settings were determined, see
54-
# https://github.com/planetlabs/planet-client-python/issues/580
55-
READ_TIMEOUT = 30.0
53+
DEFAULT_READ_TIMEOUT_SECS = 125.0
5654
RATE_LIMIT = 10 # per second
5755
MAX_ACTIVE = 50
5856

@@ -231,7 +229,11 @@ class Session(BaseSession):
231229
```
232230
"""
233231

234-
def __init__(self, auth: Optional[AuthType] = None):
232+
def __init__(
233+
self,
234+
auth: Optional[AuthType] = None,
235+
read_timeout_secs: Optional[float] = None,
236+
):
235237
"""Initialize a Session.
236238
237239
Parameters:
@@ -246,8 +248,12 @@ def __init__(self, auth: Optional[AuthType] = None):
246248
except exceptions.PlanetError:
247249
auth = Auth.from_file()
248250

249-
LOGGER.info(f'Session read timeout set to {READ_TIMEOUT}.')
250-
timeout = httpx.Timeout(10.0, read=READ_TIMEOUT)
251+
if read_timeout_secs is None:
252+
read_timeout_secs = DEFAULT_READ_TIMEOUT_SECS
253+
254+
LOGGER.info(
255+
f'Session read timeout set to {read_timeout_secs} seconds.')
256+
timeout = httpx.Timeout(10.0, read=read_timeout_secs)
251257

252258
headers = {
253259
'User-Agent': self._get_user_agent(), 'X-Planet-App': 'python-sdk'

0 commit comments

Comments
 (0)