You're simply misunderstanding mqtt fundamental concepts. Topics
are only defined by subscribers and publishers. There's no such
thing as subscribing to a topic that doesn't exist. You
subscribed to it, which makes it exist. Whether anyone else will
publish to it is irrelevant.
So your code isn't "hanging" it's "waiting for a message to be
published, as requested" It's potentially not unreasonable for
the "simple" apis to have timeouts, but they are the "simple"
apis. You can always just subscribe, run your network loop for
your timeout value, and then exit.
> and on line 170 in the callback there is a
> client.loop_forever(). The only disconnect()s are in the
> _on_message_simple() internal callback on lines 57 and 62.
> So it doesn't look like simple() will ever return when the
> topic does not exist. It will loop forever waiting for an
> incoming message that may never arrive.
> If I want to implement this I think I will have to alter that.
> Probably change the loop_forever() to something like this, and
> add a timeout argument to the callback() function. I'll try it
> later as it is too late tonight to focus on it.
> Your thoughts?
> if timeout:
> for i in range(timeout):
> On Monday, October 1, 2018 at 12:51:35 AM UTC-4,
> > I am using the following code with paho.mqtt.subscribe.simple
> > <https://www.eclipse.org/paho/clients/python/docs/#subscribe-unsubscribe