diff --git a/pymodbus/client/base.py b/pymodbus/client/base.py index cf03882d4..06bbe0a1f 100644 --- a/pymodbus/client/base.py +++ b/pymodbus/client/base.py @@ -79,12 +79,9 @@ def register(self, custom_response_class: ModbusResponse) -> None: """ self.ctx.framer.decoder.register(custom_response_class) - def close(self, reconnect: bool = False) -> None: + def close(self) -> None: """Close connection.""" - if reconnect: - self.ctx.connection_lost(asyncio.TimeoutError("Server not responding")) - else: - self.ctx.close() + self.ctx.close() def execute(self, request: ModbusRequest): """Execute request and get response (call **sync/async**). @@ -124,7 +121,7 @@ async def async_execute(self, request) -> ModbusResponse: except asyncio.exceptions.TimeoutError: count += 1 if count > self.retries: - self.close(reconnect=True) + self.ctx.connection_lost(asyncio.TimeoutError("Server not responding")) raise ModbusIOException( f"ERROR: No response received after {self.retries} retries" ) diff --git a/pymodbus/client/serial.py b/pymodbus/client/serial.py index 2da85a2ba..9e3814b84 100644 --- a/pymodbus/client/serial.py +++ b/pymodbus/client/serial.py @@ -102,10 +102,6 @@ def __init__( # pylint: disable=too-many-arguments on_connect_callback, ) - def close(self, reconnect: bool = False) -> None: - """Close connection.""" - super().close(reconnect=reconnect) - class ModbusSerialClient(ModbusBaseSyncClient): """**ModbusSerialClient**. diff --git a/pymodbus/client/tcp.py b/pymodbus/client/tcp.py index 0a431a5d2..0f6f0de44 100644 --- a/pymodbus/client/tcp.py +++ b/pymodbus/client/tcp.py @@ -51,8 +51,6 @@ async def run(): Please refer to :ref:`Pymodbus internals` for advanced usage. """ - socket: socket.socket | None - def __init__( # pylint: disable=too-many-arguments self, host: str, @@ -85,10 +83,6 @@ def __init__( # pylint: disable=too-many-arguments on_connect_callback, ) - def close(self, reconnect: bool = False) -> None: - """Close connection.""" - super().close(reconnect=reconnect) - class ModbusTcpClient(ModbusBaseSyncClient): """**ModbusTcpClient**. diff --git a/pymodbus/client/udp.py b/pymodbus/client/udp.py index 23c6db759..296d1ae46 100644 --- a/pymodbus/client/udp.py +++ b/pymodbus/client/udp.py @@ -84,11 +84,6 @@ def __init__( # pylint: disable=too-many-arguments ) self.source_address = source_address - @property - def connected(self): - """Return true if connected.""" - return self.ctx.is_active() - class ModbusUdpClient(ModbusBaseSyncClient): """**ModbusUdpClient**.