-
Notifications
You must be signed in to change notification settings - Fork 377
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
Feedback requested: Python SDK config and status object for debugging #1082
base: v3
Are you sure you want to change the base?
Conversation
thread_is_alive: bool = False | ||
len_out_mesage_queue: int = 0 | ||
len_in_message_queue: int = 0 | ||
len_out_pakcet_queue: int = 0 |
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.
Spelling?
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.
Well I like it.
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.
Comments
@@ -14,6 +14,8 @@ | |||
from . import transport_exceptions as exceptions | |||
from enum import Enum | |||
import socks | |||
import dataclasses |
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.
Since this requires Python 3.7, there should be an update to the setup.py
to exclude Python 3.6 (and a removal of the associated classifier)
@dataclasses.dataclass | ||
class PahoStatus(object): | ||
connect_rc_codes: dict = dataclasses.field(default_factory=dict) | ||
"""Value->count dictionary of rc codes returned from the `connect` method""" |
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.
This is.... super nitpicky... (but also kind of not) but you aren't supposed to use """ to make comments anywhere except a docstring. As I recall, they are interpreted differently by the runtime, because the """ is a string literal, wheras a # comment just gets completely ignored.
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.
No, not nitpicky. These string literals end up taking space at runtime, so the distinction is important. I did it this way on purpose. Even though docstrings on attributes are technically not part of the Python standard, some tools will pick these up (if you put them after the attribute definition). I think PyCharm will pick these up, and maybe some versions of Sphynx.
""" | ||
config = PahoConfig() | ||
|
||
config.transport = self._mqtt_client._transport |
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 feel as though accessing convention-private attributes of Paho is dangerous. There is no guarantee they don't change in an update to Paho, which could break anyone using our library until we make an update. Furthermore, that risk doesn't really seem worth it for a logging utility.
I could be convinced of the utility if we were to build some exception handling in to protect against this possibility, but even still, seems dicey.
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 agree that it's dangerous. I also think it's super useful -- at least some of these are. Using getattr() with a default would be much safer.
@@ -64,28 +64,39 @@ def transport_to_port(transport): | |||
) | |||
|
|||
|
|||
def disconnect_output_port(disconnect_type, transport, host): | |||
def disconnect_output_port(disconnect_type, transport, host=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.
Great change. Was thinking of doing this myself.
Looking for feedback on mqtt_transport.py changes. Tony and I have been talking about something like this as a way for customers to get a quick status on the health of our library. This is far from complete, but the intention is to provide data for observability/debugging only with the hope of avoiding the need to pour through reams of debug data.
The config object looks like this;
and the status object looks like this: