-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Python: 3.8
Pymodbus: 3.4.0
used on: UDP Client (for our example connection to nowhere, or not existed address)
Bug:
https://github.com/pymodbus-dev/pymodbus/blob/dev/pymodbus/client/base.py#L193
Future is created only ONCE
code tries to use retries, first time it is ok, when more times then wait_for using CANCELLED future!
FIX:
move req = self._build_response(request.transaction_id) to wait_for
async def async_execute(self, request=None):
"""Execute requests asynchronously."""
request.transaction_id = self.transaction.getNextTID()
packet = self.framer.buildPacket(request)
self.transport_send(packet)
if self.params.broadcast_enable and not request.slave_id:
resp = b"Broadcast write sent - no response expected"
else:
count = 0
while count < self.params.retries:
count += 1
try:
req = self._build_response(request.transaction_id)
resp = await asyncio.wait_for(
req, timeout=self.comm_params.timeout_connect
)
break
except asyncio.exceptions.TimeoutError:
pass
if count == self.params.retries:
self.close(reconnect=True)
raise ModbusIOException(
f"ERROR: No response received after {self.params.retries} retries"
)
return respMetadata
Metadata
Assignees
Labels
No labels