Skip to content

Commit 5562aff

Browse files
committed
subscriptions get_results_csv uses session.stream
see #1059
1 parent 32f826d commit 5562aff

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
@@ -336,7 +336,6 @@ async def get_results_csv(
336336
# during streaming. We may want to consider a retry decorator
337337
# for this entire method a la stamina:
338338
# https://github.com/hynek/stamina.
339-
async with self._session._client.stream('GET', url,
340-
params=params) as response:
339+
async with self._session.stream('GET', url, params=params) as response:
341340
async for line in response.aiter_lines():
342341
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)