File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -297,10 +297,17 @@ async def async_receive_data_socket(
297
297
298
298
299
299
async def _async_receive_stream (reader : asyncio .StreamReader , length : int ) -> memoryview :
300
- bytes = await reader .read (length )
301
- if len (bytes ) == 0 :
302
- raise OSError ("connection closed" )
303
- return memoryview (bytes )
300
+ mv = bytearray (length )
301
+ total_read = 0
302
+
303
+ while total_read < length :
304
+ bytes = await reader .read (length )
305
+ chunk_length = len (bytes )
306
+ if chunk_length == 0 :
307
+ raise OSError ("connection closed" )
308
+ mv [total_read :] = bytes
309
+ total_read += chunk_length
310
+ return memoryview (mv )
304
311
305
312
def receive_data (conn : Connection , length : int , deadline : Optional [float ]) -> memoryview :
306
313
buf = bytearray (length )
You can’t perform that action at this time.
0 commit comments