David %!s(int64=10) %!d(string=hai) anos
pai
achega
17ade07068
Modificáronse 1 ficheiros con 6 adicións e 4 borrados
  1. 6 4
      pmanager/pmanager.py

+ 6 - 4
pmanager/pmanager.py

@@ -97,16 +97,18 @@ class PManager:
         except Exception as e:
             print(e)
 
-    def conn(self, target):
+    def conn(self, target, timeout=None):
         if self.ws is None:
             self.ws = websocket.WebSocket()
         try:
             self.ws.connect(target)
         except Exception as e:
             log(e)
-            time.sleep(2)
-            self.conn(target) #keep trying you basterd
-    
+            if timeout is None:
+                timeout = 2
+            timeout = min(timeout, 90)
+            time.sleep(timeout)
+            self.conn(target, timeout+2) #keep trying you basterd
     
     def close(self):
         if self.ws is None: