File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 44import asyncio
55import dataclasses
66import ssl
7+ import sys
78from contextlib import suppress
89from enum import Enum
910from typing import Any , Callable , Coroutine
1415
1516NULLMODEM_HOST = "__pymodbus_nullmodem"
1617
18+ if sys .version_info .minor == 11 :
19+ USEEXCEPTIONS : tuple [type [Any ], type [Any ]] | type [Any ] = OSError
20+ else :
21+ USEEXCEPTIONS = (
22+ asyncio .TimeoutError ,
23+ OSError ,
24+ )
25+
1726
1827class CommType (Enum ):
1928 """Type of transport"""
@@ -229,10 +238,7 @@ async def transport_connect(self) -> bool:
229238 self .call_create (),
230239 timeout = self .comm_params .timeout_connect ,
231240 )
232- except (
233- asyncio .TimeoutError ,
234- OSError ,
235- ) as exc :
241+ except USEEXCEPTIONS as exc :
236242 Log .warning ("Failed to connect {}" , exc )
237243 self .transport_close (intern = True , reconnect = True )
238244 return False
You can’t perform that action at this time.
0 commit comments