Add properties to access Client attributes#794
Conversation
akx
left a comment
There was a problem hiding this comment.
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?
| # 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.
I think this should just raise a RuntimeError if the behavior is undefined?
There was a problem hiding this comment.
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.
| if self._will_topic is None: | ||
| return None | ||
|
|
||
| return self._will_topic.decode("utf-8") |
There was a problem hiding this comment.
.decode("utf-8") is at odds with the type signature bytes | None.
There was a problem hiding this comment.
It's also odd that we use self._will_TOPIC in the will_PAYLOAD property. Copy/paste is not always your friend :)
| return self._logger | ||
|
|
||
| @logger.setter | ||
| def logger(self, value: logging.Logger) -> None: |
|
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 <akx@iki.fi>
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