Skip to content

Commit 146ae72

Browse files
authored
http: increase default read timeout; make configurable (#1103)
1 parent 3ae25f9 commit 146ae72

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

CHANGES.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
Changelog moved to https://github.com/planetlabs/planet-client-python/releases
2+
13
2.13.0 (2024-12-18)
24
- Add Planet class (`from planet import Planet`)
3-
- Planet is a client that uses sync methods. Users do not have
5+
- Planet is a client that uses sync methods. Users do not have
46
to interact with asyncio to use the sync client.
57
- the Planet class is implemented by calling out to the async methods.
68
This should be transparent to users. Depending on uptake and feedback,

planet/http.py

+13-6
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,11 +229,16 @@ 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:
238240
auth: Planet server authentication.
241+
read_timeout_secs: Maximum time to wait for data to be received.
239242
"""
240243
if auth is None:
241244
# Try getting credentials from environment before checking
@@ -246,8 +249,12 @@ def __init__(self, auth: Optional[AuthType] = None):
246249
except exceptions.PlanetError:
247250
auth = Auth.from_file()
248251

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

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

0 commit comments

Comments
 (0)