Skip to content

Commit f297787

Browse files
authored
Merge pull request #1060 from planetlabs/1059-get-results-csv-not-throttled
subscriptions get_results_csv uses session.stream
2 parents be50c3a + 5562aff commit f297787

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

planet/clients/subscriptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ async def get_results_csv(
395395
# during streaming. We may want to consider a retry decorator
396396
# for this entire method a la stamina:
397397
# https://github.com/hynek/stamina.
398-
async with self._session._client.stream('GET', url,
399-
params=params) as response:
398+
async with self._session.stream('GET', url, params=params) as response:
400399
async for line in response.aiter_lines():
401400
yield line

planet/http.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,11 @@ async def _send(self, request, stream=False) -> httpx.Response:
396396

397397
@asynccontextmanager
398398
async def stream(
399-
self, method: str,
400-
url: str) -> AsyncGenerator[models.StreamingResponse, None]:
399+
self,
400+
method: str,
401+
url: str,
402+
params: Optional[dict] = None
403+
) -> AsyncGenerator[models.StreamingResponse, None]:
401404
"""Submit a request and get the response as a stream context manager.
402405
403406
Parameters:
@@ -407,7 +410,9 @@ async def stream(
407410
Returns:
408411
Context manager providing the streaming response.
409412
"""
410-
request = self._client.build_request(method=method, url=url)
413+
request = self._client.build_request(method=method,
414+
url=url,
415+
params=params)
411416
http_response = await self._retry(self._send, request, stream=True)
412417
response = models.StreamingResponse(http_response)
413418
try:

planet/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ async def aiter_bytes(self):
7272
async for c in self._http_response.aiter_bytes():
7373
yield c
7474

75+
def aiter_lines(self):
76+
return self._http_response.aiter_lines()
77+
7578
async def aclose(self):
7679
await self._http_response.aclose()
7780

0 commit comments

Comments
 (0)