diff --git a/README.rst b/README.rst index c720ce743..232f90906 100644 --- a/README.rst +++ b/README.rst @@ -114,7 +114,7 @@ I get time doing such tasks as: License Information ------------------------------------------------------------ -Pymodbus is built on top of code developed from by: +Pymodbus is built on top of code developed from/by: * Copyright (c) 2001-2005 S.W.A.C. GmbH, Germany. * Copyright (c) 2001-2005 S.W.A.C. Bohemia s.r.o., Czech Republic. * Hynek Petrak diff --git a/pymodbus/client/async.py b/pymodbus/client/async.py index 25b64ffef..3220c91b6 100644 --- a/pymodbus/client/async.py +++ b/pymodbus/client/async.py @@ -38,6 +38,7 @@ def process(): from pymodbus.exceptions import ConnectionException from pymodbus.transaction import ModbusSocketFramer, ModbusTransactionManager from pymodbus.client.common import ModbusClientMixin +from twisted.python.failure import Failure #---------------------------------------------------------------------------# # Logging @@ -82,6 +83,9 @@ def connectionLost(self, reason): ''' _logger.debug("Client disconnected from modbus server: %s" % reason) self._connected = False + while self._requests: + self._requests.popleft().errback(Failure( + ConnectionException('Connection lost during request'))) def dataReceived(self, data): ''' Get response, check for valid message, decode result @@ -111,7 +115,8 @@ def _buildResponse(self): :returns: A defer linked to the latest request ''' if not self._connected: - return defer.fail(ConnectionException('Client is not connected')) + return defer.fail(Failure( + ConnectionException('Client is not connected'))) d = defer.Deferred() self._requests.append(d) diff --git a/pymodbus/client/common.py b/pymodbus/client/common.py index 91ee380e5..aa2a5745d 100644 --- a/pymodbus/client/common.py +++ b/pymodbus/client/common.py @@ -1,4 +1,10 @@ ''' +Modbus Client Common +---------------------------------- + +This is a common client mixin that can be used by +both the synchronous and asynchronous clients to +simplify the interface. ''' from pymodbus.bit_read_message import * from pymodbus.bit_write_message import *