File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -485,7 +485,9 @@ async def aread(self) -> bytes:
485485 """
486486 if not hasattr (self , "_content" ):
487487 assert isinstance (self .stream , typing .AsyncIterable )
488- self ._content = b"" .join ([part async for part in self .stream ])
488+ async with safe_async_iterate (self .stream ) as iterator :
489+ self ._content = b"" .join ([part async for part in iterator ])
490+
489491 if not isinstance (self .stream , ByteStream ):
490492 # If a streaming request has been read entirely into memory, then
491493 # we can replace the stream with a raw bytes implementation,
@@ -976,7 +978,8 @@ async def aread(self) -> bytes:
976978 Read and return the response content.
977979 """
978980 if not hasattr (self , "_content" ):
979- self ._content = b"" .join ([part async for part in self .aiter_bytes ()])
981+ async with safe_async_iterate (self .aiter_bytes ()) as iterator :
982+ self ._content = b"" .join ([part async for part in iterator ])
980983 return self ._content
981984
982985 async def aiter_bytes (self , chunk_size : int | None = None ) -> AsyncGenerator [bytes ]:
You can’t perform that action at this time.
0 commit comments