-
Notifications
You must be signed in to change notification settings - Fork 721
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
Add properties to access Client attributes #794
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammatical etc. fixes within – and also, I'm not sure there should be setters at all for the properties which won't take an effect until reconnect? Are there actual use cases for those?
src/paho/mqtt/client.py
Outdated
# The issue here is that the previous value of keepalive matter to possibly | ||
# sent ping packet. | ||
warnings.warn( | ||
"updating keepalive on established connection is not supported", | ||
stacklevel=2, | ||
) | ||
self._sock.settimeout(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should just raise a RuntimeError if the behavior is undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used warnings because in some case it will work... but only some. I'll change to error as it will avoid user trying to use this unsupported usage.
src/paho/mqtt/client.py
Outdated
if self._will_topic is None: | ||
return None | ||
|
||
return self._will_topic.decode("utf-8") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.decode("utf-8")
is at odds with the type signature bytes | None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also odd that we use self._will_TOPIC
in the will_PAYLOAD property. Copy/paste is not always your friend :)
src/paho/mqtt/client.py
Outdated
return self._logger | ||
|
||
@logger.setter | ||
def logger(self, value: logging.Logger) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't unset the logger?
I've added setter, because some properties can't be changed without setter (at least connection_timeout), and then I've added setter for other for consistency. But I'm also unsure this will be very useful. |
3d4f413
to
e7fa784
Compare
b065003
to
1f3a4e9
Compare
I'm going with disallowing (raise RuntimeError) changing properties that need to reconnect. It's only allowed to change them when not connected or connecting. It still disallowed if the connection is currently down because a loop_forever or loop_start might reconnect concurrently. It's required to disconnect() which ensure no automatic reconnection occur |
Co-authored-by: Aarni Koskela <[email protected]>
It's now possible to known when client is connecting/connected and disconnecting/disconnected. The difference between the two state is mostly whether the connection is opened or not. This will allow to avoid a reconnection while a reconnection is ongoing.
1f3a4e9
to
fed93d9
Compare
fed93d9
to
c713c57
Compare
Fix #764, add properties for