I'm running pytest against my server which happens to require a login.
As the connection didn't succeed I'd expect the async with AsyncMQTTClient() call to raise an appropriate exception instead of continuing.
-> async def _run_operation(self, operation: MQTTOperation[Any]) -> None:
(Pdb) b 481
Breakpoint 1 at /src/mqttproto/src/mqttproto/async_client.py:481
(Pdb) c
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB continue >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /src/mqttproto/src/mqttproto/async_client.py(481)_run_operation()
-> if operation.exception:
(Pdb) p operation.exception
None
(Pdb) p operation.response.reason_code
<ReasonCode.NOT_AUTHORIZED: 135>
(Pdb) c
………
| Traceback (most recent call last):
| File "/src/mqttproto/tests/test_async_client.py", line 14, in test_publish_subscribe
| async with client.subscribe("test/+") as messages:
…
| mqttproto.MQTTProtocolError: cannot perform this operation in the DISCONNECTED state (must be in one of the following states: CONNECTED)
My goal was to provide transparent handling of intermittent issues, but maybe I went too far in trying to hide problems from the user. What would you suggest?
I'm running pytest against my server which happens to require a login.
As the connection didn't succeed I'd expect the
async with AsyncMQTTClient()
call to raise an appropriate exception instead of continuing.