Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Changelog moved to https://github.com/planetlabs/planet-client-python/releases

2.13.0 (2024-12-18)
- Add Planet class (`from planet import Planet`)
- Planet is a client that uses sync methods. Users do not have
- Planet is a client that uses sync methods. Users do not have
to interact with asyncio to use the sync client.
- the Planet class is implemented by calling out to the async methods.
This should be transparent to users. Depending on uptake and feedback,
Expand Down
19 changes: 13 additions & 6 deletions planet/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
MAX_RETRIES = 5
MAX_RETRY_BACKOFF = 64 # seconds

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

Expand Down Expand Up @@ -231,11 +229,16 @@ class Session(BaseSession):
```
"""

def __init__(self, auth: Optional[AuthType] = None):
def __init__(
self,
auth: Optional[AuthType] = None,
read_timeout_secs: Optional[float] = None,
):
"""Initialize a Session.

Parameters:
auth: Planet server authentication.
read_timeout_secs: Maximum time to wait for data to be received.
"""
if auth is None:
# Try getting credentials from environment before checking
Expand All @@ -246,8 +249,12 @@ def __init__(self, auth: Optional[AuthType] = None):
except exceptions.PlanetError:
auth = Auth.from_file()

LOGGER.info(f'Session read timeout set to {READ_TIMEOUT}.')
timeout = httpx.Timeout(10.0, read=READ_TIMEOUT)
if read_timeout_secs is None:
read_timeout_secs = DEFAULT_READ_TIMEOUT_SECS

LOGGER.info(
f'Session read timeout set to {read_timeout_secs} seconds.')
timeout = httpx.Timeout(10.0, read=read_timeout_secs)

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