Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Best Practice to not-block connect() in Python

Hi All,

I'm trying to add some error conditions to my basic paho-mqtt code and
am curious what others use for conditions when a broker is unavailable
to not block a call? If I had something like:

# broker becomes unreachable
client.publish.single()   # With TLS 1.2

or:

client.set_tls(xxx)
client.connect(keepalive=10)   # with on_connect callback

the thread blocks on the connection. I have worked around this by
having messages published create a greenlet with a timeout value and
call the publish method with a timeout. Is there a more elegant way to
do this or something I'm missing?

Have search a lot of code snippets and I would be happy to see some
examples. Thanks!

-- 

Regards,

--- Gavin


Back to the top