Skip to content
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

Propagate return values of Paho's original client methods #131

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions locust_plugins/users/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import paho.mqtt.client as mqtt

if typing.TYPE_CHECKING:
from paho.mqtt.client import MQTTMessageInfo
from paho.mqtt.properties import Properties
from paho.mqtt.subscribeoptions import SubscribeOptions

Expand Down Expand Up @@ -303,7 +304,7 @@ def publish(
qos: int = 0,
retain: bool = False,
properties: typing.Optional[Properties] = None,
):
) -> MQTTMessageInfo:
"""Publish a message to the MQTT broker.

This method wraps the underlying paho-mqtt client's method in order to
Expand Down Expand Up @@ -334,13 +335,15 @@ def publish(
# store this for use in the on_publish callback
self._publish_requests[publish_info.mid] = request_context

return publish_info

def subscribe(
self,
topic: str,
qos: int = 0,
options: typing.Optional[SubscribeOptions] = None,
properties: typing.Optional[Properties] = None,
):
) -> typing.Tuple[int, typing.Optional[int]]:
"""Subscribe to a given topic.

This method wraps the underlying paho-mqtt client's method in order to
Expand Down Expand Up @@ -368,3 +371,5 @@ def subscribe(
)
else:
self._subscribe_requests[mid] = request_context

return result, mid