Skip to content

Async client functions return None on no response. #2500

Closed
@philj56

Description

@philj56

Versions

  • Pymodbus: 3.8.0

Description

Previously, a timeout during a call to e.g. client.read_coils would log an error and return an exception response. As of 3.8.0, this instead returns None in the async client, which breaks the normal usage of PyModbus as given in the documentation:

try:
    rr = await client.read_coils(1, 1, slave=1)
except ModbusException as exc:
    _logger.error(f"ERROR: exception in pymodbus {exc}")
    raise exc
if rr.isError():  # Error: NoneType has attribute 'isError'.
    _logger.error("ERROR: pymodbus returned an error!")
    raise ModbusException(txt)

This can be seen by comparing TransactionManager's sync_execute:

txt = f"No response received after {self.retries} retries, continue with next request"
Log.error(txt)
raise ModbusIOException(txt)

with execute:

Log.error(f"No response received after {self.retries} retries, continue with next request")
self.response_future = asyncio.Future()
return None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions