Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async client functions return None on no response. #2500

Closed
philj56 opened this issue Dec 13, 2024 · 1 comment · Fixed by #2502
Closed

Async client functions return None on no response. #2500

philj56 opened this issue Dec 13, 2024 · 1 comment · Fixed by #2502

Comments

@philj56
Copy link
Contributor

philj56 commented Dec 13, 2024

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
@janiversen
Copy link
Collaborator

good catch, looks like a bug, pull requests are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants