2121from .._download import _ChunkDownloader
2222from .._shared .request_handlers import validate_and_format_range_headers
2323from .._shared .response_handlers import parse_length_from_content_range , process_storage_error
24+ from .._shared .constants import DEFAULT_MAX_CONCURRENCY
2425
2526if TYPE_CHECKING :
2627 from .._generated .aio .operations import FileOperations
@@ -178,7 +179,7 @@ def __init__(
178179 start_range : Optional [int ] = None ,
179180 end_range : Optional [int ] = None ,
180181 validate_content : bool = None , # type: ignore [assignment]
181- max_concurrency : int = 1 ,
182+ max_concurrency : Optional [ int ] = None ,
182183 name : str = None , # type: ignore [assignment]
183184 path : str = None , # type: ignore [assignment]
184185 share : str = None , # type: ignore [assignment]
@@ -194,7 +195,7 @@ def __init__(
194195 self ._config = config
195196 self ._start_range = start_range
196197 self ._end_range = end_range
197- self ._max_concurrency = max_concurrency
198+ self ._max_concurrency = max_concurrency if max_concurrency is not None else DEFAULT_MAX_CONCURRENCY
198199 self ._encoding = encoding
199200 self ._validate_content = validate_content
200201 self ._progress_hook = kwargs .pop ('progress_hook' , None )
@@ -358,7 +359,7 @@ async def readall(self) -> bytes:
358359 return data .decode (self ._encoding ) # type: ignore [return-value]
359360 return data
360361
361- async def content_as_bytes (self , max_concurrency = 1 ):
362+ async def content_as_bytes (self , max_concurrency = None ):
362363 """DEPRECATED: Download the contents of this file.
363364
364365 This operation is blocking until all data is downloaded.
@@ -374,10 +375,10 @@ async def content_as_bytes(self, max_concurrency=1):
374375 "content_as_bytes is deprecated, use readall instead" ,
375376 DeprecationWarning
376377 )
377- self ._max_concurrency = max_concurrency
378+ self ._max_concurrency = max_concurrency if max_concurrency is not None else DEFAULT_MAX_CONCURRENCY
378379 return await self .readall ()
379380
380- async def content_as_text (self , max_concurrency = 1 , encoding = "UTF-8" ):
381+ async def content_as_text (self , max_concurrency = None , encoding = "UTF-8" ):
381382 """DEPRECATED: Download the contents of this file, and decode as text.
382383
383384 This operation is blocking until all data is downloaded.
@@ -395,7 +396,7 @@ async def content_as_text(self, max_concurrency=1, encoding="UTF-8"):
395396 "content_as_text is deprecated, use readall instead" ,
396397 DeprecationWarning
397398 )
398- self ._max_concurrency = max_concurrency
399+ self ._max_concurrency = max_concurrency if max_concurrency is not None else DEFAULT_MAX_CONCURRENCY
399400 self ._encoding = encoding
400401 return await self .readall ()
401402
@@ -480,7 +481,7 @@ async def readinto(self, stream: IO[bytes]) -> int:
480481 process_storage_error (error )
481482 return self .size
482483
483- async def download_to_stream (self , stream , max_concurrency = 1 ):
484+ async def download_to_stream (self , stream , max_concurrency = None ):
484485 """Download the contents of this file to a stream.
485486
486487 This method is deprecated, use func:`readinto` instead.
@@ -498,6 +499,6 @@ async def download_to_stream(self, stream, max_concurrency=1):
498499 "download_to_stream is deprecated, use readinto instead" ,
499500 DeprecationWarning
500501 )
501- self ._max_concurrency = max_concurrency
502+ self ._max_concurrency = max_concurrency if max_concurrency is not None else DEFAULT_MAX_CONCURRENCY
502503 await self .readinto (stream )
503504 return self .properties
0 commit comments