@@ -88,7 +88,7 @@ async def _():
8888
8989 async def _stream (
9090 self , method : Literal ["GET" ], url : str , * args , ** kwargs
91- ) -> AsyncGenerator [bytes , None ]:
91+ ) -> AsyncGenerator [httpx . Response , None ]:
9292 n_attempts = self .configuration .retries .total
9393 assert isinstance (n_attempts , int )
9494
@@ -98,17 +98,15 @@ async def _stream(
9898 stop = tenacity .stop_after_attempt (n_attempts ),
9999 retry = tenacity .retry_if_exception_type (httpx .HTTPStatusError ),
100100 )
101- async def _ () -> AsyncGenerator [bytes , None ]:
101+ async def _ () -> AsyncGenerator [httpx . Response , None ]:
102102 async with self ._client .stream (
103103 method = method , url = url , * args , ** kwargs
104104 ) as response :
105105 if response .status_code in self .configuration .retries .status_forcelist :
106106 response .raise_for_status ()
107- async for chunk in response .aiter_bytes ():
108- yield chunk
107+ yield response
109108
110- async for chunk in _ ():
111- yield chunk
109+ return _ ()
112110
113111 async def put (self , * args , ** kwargs ) -> httpx .Response :
114112 return await self ._request (self ._client .put , * args , ** kwargs )
@@ -127,9 +125,8 @@ async def get(self, *args, **kwargs) -> httpx.Response:
127125
128126 async def stream (
129127 self , method : Literal ["GET" ], url : str , * args , ** kwargs
130- ) -> AsyncGenerator [bytes , None ]:
131- async for chunk in self ._stream (method = method , url = url , * args , ** kwargs ):
132- yield chunk
128+ ) -> AsyncGenerator [httpx .Response , None ]:
129+ return await self ._stream (method = method , url = url , * args , ** kwargs )
133130
134131 def _wait_callback (self , retry_state : tenacity .RetryCallState ) -> int :
135132 assert retry_state .outcome is not None
0 commit comments