Skip to content

Commit d3d0b4f

Browse files
author
Paul Sokolovsky
committed
umqtt.robust: Add universal with_retry method, and publish_() using it.
This method uses more memory though.
1 parent 4dc1f1c commit d3d0b4f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

umqtt.robust/umqtt/robust.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ def reconnect(self):
2626
i += 1
2727
self.delay(i)
2828

29+
def with_retry(self, meth, *args, **kwargs):
30+
while 1:
31+
try:
32+
return meth(*args, **kwargs)
33+
except OSError as e:
34+
print("%r" % e)
35+
time.sleep(0.5)
36+
self.reconnect()
37+
38+
def publish_(self, *args, **kwargs):
39+
return self.with_retry(super().publish, *args, **kwargs)
40+
2941
def publish(self, topic, msg, retain=False, qos=0):
3042
while 1:
3143
try:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy