agronholm / agronholm/mqttproto

Connection failure doesn't raise an exception

Offen
#16 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
23
Forks
6
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

(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)
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.