Skip to content

Commit 033bf92

Browse files
SpEcHiDeeyMarv
andcommitted
steal fixes from pyroblack
Co-authored-by: eyMarv <eyMarv07@gmail.com>
1 parent 8bdfea3 commit 033bf92

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pyrogram/session/session.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
RPCError, InternalServerError, AuthKeyDuplicated,
3434
FloodWait, FloodPremiumWait,
3535
ServiceUnavailable, BadMsgNotification,
36-
SecurityCheckMismatch
36+
SecurityCheckMismatch,
37+
Unauthorized
3738
)
3839
from pyrogram.raw.all import layer
3940
from pyrogram.raw.core import TLObject, MsgContainer, Int, FutureSalts
@@ -58,6 +59,7 @@ class Session:
5859
PING_INTERVAL = 5
5960
STORED_MSG_IDS_MAX_SIZE = 1000 * 2
6061
RECONNECT_THRESHOLD = 13
62+
STOP_RANGE = range(2)
6163

6264
TRANSPORT_ERRORS = {
6365
404: "auth key not found",
@@ -197,7 +199,7 @@ async def stop(self, restart: bool = False):
197199
self.instant_stop = True # tell all funcs that we want to stop
198200

199201
self.ping_task_event.set()
200-
for _ in range(2):
202+
for _ in self.STOP_RANGE:
201203
try:
202204
if self.ping_task is not None:
203205
await asyncio.wait_for(
@@ -216,7 +218,7 @@ async def stop(self, restart: bool = False):
216218
except Exception as e:
217219
log.exception(e)
218220

219-
for _ in range(2):
221+
for _ in self.STOP_RANGE:
220222
try:
221223
if self.recv_task:
222224
await asyncio.wait_for(
@@ -252,7 +254,7 @@ async def restart(self):
252254
self.last_reconnect_attempt
253255
and (now - self.last_reconnect_attempt) < self.RECONNECT_THRESHOLD
254256
):
255-
to_wait = int(
257+
to_wait = self.RECONNECT_THRESHOLD + int(
256258
self.RECONNECT_THRESHOLD - (now - self.last_reconnect_attempt)
257259
)
258260
log.warning(

0 commit comments

Comments
 (0)