@@ -16,7 +16,7 @@ def __init__(self, loop, protocol, *args, **kwargs):
1616 """Initialize."""
1717 super ().__init__ ()
1818 self .async_loop = loop
19- self ._protocol = protocol
19+ self ._protocol : asyncio . BaseProtocol = protocol
2020 self .sync_serial = serial .serial_for_url (* args , ** kwargs )
2121 self ._closing = False
2222 self ._write_buffer = []
@@ -37,7 +37,7 @@ def __init__(self, loop, protocol, *args, **kwargs):
3737 @property
3838 def loop (self ):
3939 """Return asyncio event loop."""
40- return self ._protocol . loop
40+ return self .async_loop
4141
4242 def get_protocol (self ) -> asyncio .BaseProtocol :
4343 """Return protocol"""
@@ -95,7 +95,7 @@ def _read_ready(self):
9595 try :
9696 data = self .sync_serial .read (1024 )
9797 except serial .SerialException as exc :
98- self ._protocol . loop .call_soon (self ._call_connection_lost , exc )
98+ self .async_loop .call_soon (self ._call_connection_lost , exc )
9999 self .close ()
100100 else :
101101 if data :
@@ -130,7 +130,7 @@ def _write_ready(self):
130130 except (BlockingIOError , InterruptedError ):
131131 self ._write_buffer .append (data )
132132 except serial .SerialException as exc :
133- self ._protocol . loop .call_soon (self ._call_connection_lost , exc )
133+ self .async_loop .call_soon (self ._call_connection_lost , exc )
134134 self .abort ()
135135 else :
136136 if nlen == len (data ):
0 commit comments