-
Notifications
You must be signed in to change notification settings - Fork 71
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
Added a new parameter for configuring socket connection. #71
Conversation
…he timeout in seconds before a message with QoS>0 is retried. 20 seconds by default.
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.
Thanks for the pull request. This is a really cool feature and a nice addition to asyncio-mqtt. 👍
I've reviewed the changes and I'd like some minor changes here and there. Let me know what you think. :)
asyncio_mqtt/client.py
Outdated
# It is also possible to set all possible socket settings. | ||
# See https://docs.python.org/3/library/socket.html#socket.socket.setsockopt for more information. | ||
# If the socket_options is None, then the system defaults are used. | ||
socket_options: Optional[Tuple[int, int, Union[int, bytes]]] = (socket.SOL_SOCKET, socket.SO_SNDBUF, 2048), |
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.
Good job with the initial typing here. 👍 I really like the details in the comment as well
I suggest that we drop the default SO_SNDBUF
setting. Move it to the comment, though, as a nice example.
I also suggest that we expand on this, so that people can set multiple options using any of the three overloads of setsockopt. First, we define:
# See the overloads of `socket.setsockopt` for details.
SocketOption = Union[
Tuple[int, int, Union[int, bytes]],
Tuple[int, int, None, int],
]
Second, we accept an iterable of socket options in the Client.__init__
.
socket_options: Iterable[SocketOption],
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.
Yes, is good idea!
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 found it worth adding one more thing so that there would be no compatibility issues with the new library version when upgrading.
If we do this: socket_options: Iterable[SocketOption],
then we get an error
TypeError: init() missing 1 required keyword-only argument: 'socket_options', because we have no input parameter when constructing an object.
Maybe add a default value?
For example: socket_options: Optional[Iterable[SocketOption]] = ()
Thank you! Great changes. Thus, the setting will be more flexible. |
Glad you like it. :) Let me know when you push the new changes. 👍 For now, there seems to be some merge conflicts. I recommend that you:
That should also get rid of the "Added new parameter 'message_retry_set' to the Client._" commit that we already merged to master. :) |
…r. We now support all possible socket options setting overloads.
I applied the changes, check please:) |
I merged your pull request. Thanks for you contribution to asyncio-mqtt. :) 👍 |
Thanks for a great project! )) |
From #70 issue.