Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Paho Python Client

Dear Paho Users,

I have some fairly basic questions about the Paho Python client, most of them have to do with the fact that I am not too familiar with Python.

From an architectural perspective it seems that the Python client is highly callback based. When looking at the front page of the Paho Python website (https://eclipse.org/paho/clients/python/), the idiom to follow seems to have a onConnect callback and all further actions should happen in the onConnect callback (or other callbacks).

So my questions are:

1. Is there a synchronous / blocking mode for the API? Otherwise it seems to be introduce bugs to do something like the following snippet:

- - - START SNIPPET - - -

client.connect(….)
client.subscribe(…)
client.publish(…)

- - - END SNIPPET - - -

2. Most of the examples in git (like this file: http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.python.git/tree/examples/sub.py) seem to allow such a programming style. Are the examples obsolete? It seems the sub.py for example doesn’t always work when using different broker implementations.

3. It seems the Paho interoperability test suite also doesn’t follow the callback based programming style but use sleep(X). This seems to introduce race conditions sometimes. So shouldn’t the test suite use callbacks in order to be correct?

4. Does the subscribe(…) method wait until the suback is received before the next line in python scripts is executed? If not it would be good to add some additional sleep(X) after subscribing, I have the impression that sometimes race conditions occur when the client is not yet subscribed (at least the subscription is not acked) and the client already publishes.


Thanks,
Dominik



Back to the top