David il y a 10 ans
Parent
commit
17ade07068
1 fichiers modifiés avec 6 ajouts et 4 suppressions
  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: