File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ async def example() -> None:
14
14
response = await conn .send_modbus_message (example_message )
15
15
16
16
assert response is not None , "we expect a response from ReadCoils"
17
- print (response .data )
17
+ print (response .data ) # noqa: T201
18
18
19
19
20
20
if __name__ == "__main__" :
Original file line number Diff line number Diff line change 6
6
import time
7
7
import uuid
8
8
from dataclasses import dataclass
9
- from types import TracebackType
10
- from typing import Any , ClassVar
9
+ from typing import TYPE_CHECKING , Any , ClassVar
11
10
12
11
from cachetools import TTLCache
13
- from typing_extensions import Self
14
- from umodbus .functions import ModbusFunction
15
12
16
13
from tcp_modbus_aio .exceptions import (
17
14
ModbusCommunicationFailureError ,
24
21
create_function_from_response_pdu ,
25
22
)
26
23
24
+ if TYPE_CHECKING :
25
+ from types import TracebackType
26
+
27
+ from typing_extensions import Self
28
+ from umodbus .functions import ModbusFunction
29
+
27
30
28
31
@dataclass
29
32
class CoilWatchStatus :
@@ -308,7 +311,16 @@ async def clear_tcp_connection(self) -> None:
308
311
)
309
312
310
313
self ._writer .close ()
311
- await self ._writer .wait_closed ()
314
+
315
+ try :
316
+ await self ._writer .wait_closed ()
317
+ except TimeoutError :
318
+ if self .logger is not None :
319
+ self .logger .warning (
320
+ f"[{ self } ][clear_tcp_connection] connection close timed out, continuing anyway"
321
+ )
322
+
323
+ pass
312
324
313
325
self ._reader = None
314
326
self ._writer = None
You can’t perform that action at this time.
0 commit comments