File tree Expand file tree Collapse file tree 4 files changed +9
-3
lines changed
Expand file tree Collapse file tree 4 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 88
99#### Bug fixes
1010- Fixed an issue where ` batch.download ` and ` batch.download_async ` would fail if requested files already existed in the output directory
11+ - Fixed an issue where ` batch.download ` , ` batch.download_async ` , and ` timeseries.get_range ` could use a lot of memory while streaming data
1112
1213## 0.33.0 - 2024-04-16
1314
Original file line number Diff line number Diff line change 2525 x [0 ]: np .iinfo (x [1 ]).max for x in InstrumentDefMsg ._dtypes if not isinstance (x [1 ], str )
2626}
2727
28+ HTTP_STREAMING_READ_SIZE : Final = 2 ** 12
29+
2830SCHEMA_STRUCT_MAP : Final [dict [Schema , type [DBNRecord ]]] = {
2931 Schema .DEFINITION : InstrumentDefMsg ,
3032 Schema .IMBALANCE : ImbalanceMsg ,
Original file line number Diff line number Diff line change 2424from databento_dbn import SType
2525from requests .auth import HTTPBasicAuth
2626
27+ from databento .common .constants import HTTP_STREAMING_READ_SIZE
2728from databento .common .enums import Delivery
2829from databento .common .enums import Packaging
2930from databento .common .enums import SplitDuration
@@ -416,7 +417,7 @@ def _download_batch_file(
416417 ) as response :
417418 check_http_error (response )
418419 with open (output_path , mode = mode ) as f :
419- for chunk in response .iter_content (chunk_size = None ):
420+ for chunk in response .iter_content (chunk_size = HTTP_STREAMING_READ_SIZE ):
420421 f .write (chunk )
421422 except BentoHttpError as exc :
422423 if exc .http_status == 429 :
Original file line number Diff line number Diff line change 88from os import PathLike
99from typing import IO
1010from typing import Any
11+ from typing import Final
1112
1213import aiohttp
1314import requests
1617from requests import Response
1718from requests .auth import HTTPBasicAuth
1819
20+ from databento .common .constants import HTTP_STREAMING_READ_SIZE
1921from databento .common .dbnstore import DBNStore
2022from databento .common .error import BentoClientError
2123from databento .common .error import BentoDeprecationWarning
2527from databento .common .system import USER_AGENT
2628
2729
28- WARNING_HEADER_FIELD : str = "X-Warning"
30+ WARNING_HEADER_FIELD : Final = "X-Warning"
2931
3032
3133class BentoHttpAPI :
@@ -137,7 +139,7 @@ def _stream(
137139 writer = open (path , "x+b" )
138140
139141 try :
140- for chunk in response .iter_content (chunk_size = None ):
142+ for chunk in response .iter_content (chunk_size = HTTP_STREAMING_READ_SIZE ):
141143 writer .write (chunk )
142144 except Exception as exc :
143145 raise BentoError (f"Error streaming response: { exc } " ) from None
You can’t perform that action at this time.
0 commit comments