Skip to content

Commit 9c14a64

Browse files
committed
FIX: Fix batch download GET async
1 parent ae401f0 commit 9c14a64

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

databento/historical/api/batch.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,12 @@ async def download_async(
362362
("job_id", job_id),
363363
]
364364

365-
response: aiohttp.ClientResponse = await self._get_async(
365+
job_files: List[Dict[str, Any]] = await self._get_json_async(
366366
url=self._base_url + ".list_files",
367367
params=params,
368368
basic_auth=True,
369369
)
370370

371-
job_files: List[Dict[str, Any]] = await response.json()
372-
373371
if not job_files:
374372
log_error(f"Cannot download batch job {job_id} (no files found).")
375373
return

databento/historical/http.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from json.decoder import JSONDecodeError
33
from pathlib import Path
4-
from typing import BinaryIO, List, Optional, Tuple, Union
4+
from typing import Any, BinaryIO, List, Optional, Tuple, Union
55

66
import aiohttp
77
import requests
@@ -66,12 +66,12 @@ def _get(
6666
check_http_error(response)
6767
return response
6868

69-
async def _get_async(
69+
async def _get_json_async(
7070
self,
7171
url: str,
7272
params: Optional[List[Tuple[str, Optional[str]]]] = None,
7373
basic_auth: bool = False,
74-
) -> ClientResponse:
74+
) -> Any:
7575
self._check_api_key()
7676
async with aiohttp.ClientSession() as session:
7777
async with session.get(
@@ -84,7 +84,7 @@ async def _get_async(
8484
timeout=self.TIMEOUT,
8585
) as response:
8686
await check_http_error_async(response)
87-
return response
87+
return await response.json()
8888

8989
def _post(
9090
self,

0 commit comments

Comments
 (0)