David 10 سال پیش
والد
کامیت
17ade07068
1فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  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: