@@ -622,7 +622,6 @@ async def connect(self, force=False):
622622 async def _handler (self , ws : ClientConnection ):
623623 consumer_task = asyncio .create_task (self ._start_receiving (ws ))
624624 producer_task = asyncio .create_task (self ._start_sending (ws ))
625- # TODO should attach futures and add exceptions to them
626625 done , pending = await asyncio .wait (
627626 [consumer_task , producer_task ],
628627 return_when = asyncio .FIRST_COMPLETED ,
@@ -663,9 +662,9 @@ async def shutdown(self):
663662 self ._receiving_task = None
664663 self ._is_closing = False
665664
666- async def _recv (self , recd ) -> None :
665+ async def _recv (self , recd : bytes ) -> None :
667666 if self ._log_raw_websockets :
668- raw_websocket_logger .debug (f"WEBSOCKET_RECEIVE> { recd } " )
667+ raw_websocket_logger .debug (f"WEBSOCKET_RECEIVE> { recd . decode () } " )
669668 response = json .loads (recd )
670669 self .last_received = await self .loop_time ()
671670 if "id" in response :
@@ -678,8 +677,8 @@ async def _recv(self, recd) -> None:
678677
679678 async def _start_receiving (self , ws : ClientConnection ) -> Exception :
680679 try :
681- async for recd in ws :
682- await self ._recv (recd )
680+ while True :
681+ await self ._recv (await ws . recv ( decode = False ) )
683682 except Exception as e :
684683 if isinstance (e , ssl .SSLError ):
685684 e = ConnectionClosed
0 commit comments