File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232
3333
3434class Auth :
35+ MAX_RETRIES = 5
36+
3537 CURRENT_DH_PRIME = int (
3638 "C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F"
3739 "48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C37"
@@ -76,9 +78,10 @@ def create(self):
7678 https://core.telegram.org/mtproto/auth_key
7779 https://core.telegram.org/mtproto/samples-auth_key
7880 """
81+ retries_left = self .MAX_RETRIES
7982
8083 # The server may close the connection at any time, causing the auth key creation to fail.
81- # If that happens, just try again until it succeed .
84+ # If that happens, just try again up to MAX_RETRIES times .
8285 while True :
8386 try :
8487 log .info ("Start creating a new auth key on DC{}" .format (self .dc_id ))
@@ -243,6 +246,11 @@ def create(self):
243246 )
244247 )
245248 except Exception as e :
249+ if retries_left :
250+ retries_left -= 1
251+ else :
252+ raise e
253+
246254 log .warning ("Auth key creation failed. Let's try again: {}" .format (repr (e )))
247255 time .sleep (1 )
248256 continue
You can’t perform that action at this time.
0 commit comments