Skip to content

Commit

Permalink
Merge pull request #131 from flbraun/dont_hide_paho_retvals
Browse files Browse the repository at this point in the history
Propagate return values of Paho's original client methods
  • Loading branch information
cyberw committed Jul 11, 2023
2 parents 858a89e + 21f13df commit 203e049
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 203e049

Please sign in to comment.