@@ -33,8 +33,8 @@ async def connect(self, uri, ssl: SSLContext | None):
3333
3434 async def _recv_loop (self ):
3535 try :
36- while True :
37- data : bytes = await self ._proto .recv () # type: ignore
36+ while self . _proto :
37+ data : bytes = await self ._proto .recv (decode = False )
3838 pkg = None
3939 try :
4040 pkg = Package (data )
@@ -50,34 +50,35 @@ async def _recv_loop(self):
5050
5151 except ConnectionClosed as exc :
5252 self .cancel_requests ()
53- self ._proto = None # type: ignore
53+ self ._proto = None
5454 self ._on_connection_lost (self , exc ) # type: ignore
5555
5656 def _write (self , data : Any ):
5757 if self ._proto is None :
5858 raise ConnectionError ('no connection' )
59- asyncio .create_task (self ._proto .send (data )) # type: ignore
59+ asyncio .create_task (self ._proto .send (data ))
6060
6161 def close (self ):
6262 self ._is_closing = True
6363 if self ._proto :
64- asyncio .create_task (self ._proto .close ()) # type: ignore
64+ asyncio .create_task (self ._proto .close ())
6565
6666 def is_closing (self ) -> bool :
6767 return self ._is_closing
6868
6969 async def wait_closed (self ):
7070 if self ._proto :
71- await self ._proto .wait_closed () # type: ignore
71+ await self ._proto .wait_closed ()
7272
7373 async def close_and_wait (self ):
7474 if self ._proto :
75- await self ._proto .close () # type: ignore
75+ await self ._proto .close ()
7676
7777 def info (self ) -> Any :
78- return self ._proto .transport .get_extra_info ( # type: ignore
79- 'socket' ,
80- None )
78+ if self ._proto :
79+ return self ._proto .transport .get_extra_info (
80+ 'socket' ,
81+ None )
8182
8283 def is_connected (self ) -> bool :
8384 return self ._proto is not None
0 commit comments