Closed 4s1 closed 4 weeks ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
13b44fb
) 85.1% compared to head (1d607c0
) 85.1%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hi there, thanks for working on this! 😎
As far as I understand, #269 mentioned two different exceptions. First, MqttConnectError
thrown by the on_connect
callback (which is handled in this PR) and second, MqttError
thrown due to a timeout by wait_for
(not yet handled).
Currently, the MqttConnectError
would be cast to a MqttError
which is a breaking change. I think it'd be better to handle and reraise both exceptions in their own try/except block, something like this (not tested):
try:
await self._wait_for(self._connected, timeout=None)
except MqttError, MqttConnectError:
# Release lock and reraise any exception raised waiting on CONNACK
self._lock.release()
raise
It'd be great if you added test cases for these as well, so we/I don't accidently regress this again. To simulate the MqttConnectError
thrown by on_connect
you could use client._connected.set_exception(MqttConnectError)
. There are a few tests that already do something similar with the _disconnected
future.
I'll close this, because I believe this was fixed with #285.
Thank you nonetheless for this PR and your great comments on the corresponding issue!
Connection errors in aenter() which happen while _wait_for(selt._connected,...) were not catched, leaving a stale _lock behind, which made client non reusable.
Pull waiting for connected event into try/except block, so client is reusable in event of an error while trying to connect.
fixes #269