Skip to content

Commit 4eb26c5

Browse files
committed
Fix sleep method calls in asyncio: time.sleep -> asyncio.sleep
1 parent 2b8e485 commit 4eb26c5

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

pyrogram/client/client.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
VolumeLocNotFound, UserMigrate, FileIdInvalid, ChannelPrivate, PhoneNumberOccupied,
4949
PasswordRecoveryNa, PasswordEmpty
5050
)
51-
from pyrogram.client.handlers import DisconnectHandler
5251
from pyrogram.client.handlers.handler import Handler
5352
from pyrogram.client.methods.password.utils import compute_check
5453
from pyrogram.crypto import AES
@@ -571,7 +570,7 @@ async def default_phone_number_callback():
571570
raise
572571
else:
573572
print(e.MESSAGE.format(x=e.x))
574-
time.sleep(e.x)
573+
await asyncio.sleep(e.x)
575574
except Exception as e:
576575
log.error(e, exc_info=True)
577576
raise
@@ -707,7 +706,7 @@ async def default_recovery_callback(email_pattern: str) -> str:
707706
raise
708707
else:
709708
print(e.MESSAGE.format(x=e.x))
710-
time.sleep(e.x)
709+
await asyncio.sleep(e.x)
711710
self.password = None
712711
self.recovery_code = None
713712
except Exception as e:
@@ -721,7 +720,7 @@ async def default_recovery_callback(email_pattern: str) -> str:
721720
raise
722721
else:
723722
print(e.MESSAGE.format(x=e.x))
724-
time.sleep(e.x)
723+
await asyncio.sleep(e.x)
725724
except Exception as e:
726725
log.error(e, exc_info=True)
727726
raise

pyrogram/client/methods/chats/get_dialogs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import asyncio
1920
import logging
20-
import time
2121

2222
import pyrogram
2323
from pyrogram.api import functions, types
@@ -73,8 +73,8 @@ async def get_dialogs(self,
7373
)
7474
)
7575
except FloodWait as e:
76-
log.warning("Sleeping {}s".format(e.x))
77-
time.sleep(e.x)
76+
log.warning("Sleeping for {}s".format(e.x))
77+
await asyncio.sleep(e.x)
7878
else:
7979
break
8080

pyrogram/client/methods/messages/get_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import asyncio
1920
import logging
20-
import time
2121
from typing import Union
2222

2323
import pyrogram

pyrogram/client/methods/messages/get_messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import asyncio
1920
import logging
20-
import time
2121
from typing import Union, Iterable
2222

2323
import pyrogram
@@ -88,7 +88,7 @@ async def get_messages(self,
8888
r = await self.send(rpc)
8989
except FloodWait as e:
9090
log.warning("Sleeping for {}s".format(e.x))
91-
time.sleep(e.x)
91+
await asyncio.sleep(e.x)
9292
else:
9393
break
9494

pyrogram/session/auth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import asyncio
1920
import logging
2021
import time
2122
from hashlib import sha1
@@ -254,7 +255,7 @@ async def create(self):
254255
else:
255256
raise e
256257

257-
time.sleep(1)
258+
await asyncio.sleep(1)
258259
continue
259260
else:
260261
return auth_key

0 commit comments

Comments
 (0)