diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py
index 863856f3..267aade4 100644
--- a/pyrogram/client/client.py
+++ b/pyrogram/client/client.py
@@ -48,7 +48,6 @@ from pyrogram.api.errors import (
VolumeLocNotFound, UserMigrate, FileIdInvalid, ChannelPrivate, PhoneNumberOccupied,
PasswordRecoveryNa, PasswordEmpty
)
-from pyrogram.client.handlers import DisconnectHandler
from pyrogram.client.handlers.handler import Handler
from pyrogram.client.methods.password.utils import compute_check
from pyrogram.crypto import AES
@@ -571,7 +570,7 @@ class Client(Methods, BaseClient):
raise
else:
print(e.MESSAGE.format(x=e.x))
- time.sleep(e.x)
+ await asyncio.sleep(e.x)
except Exception as e:
log.error(e, exc_info=True)
raise
@@ -707,7 +706,7 @@ class Client(Methods, BaseClient):
raise
else:
print(e.MESSAGE.format(x=e.x))
- time.sleep(e.x)
+ await asyncio.sleep(e.x)
self.password = None
self.recovery_code = None
except Exception as e:
@@ -721,7 +720,7 @@ class Client(Methods, BaseClient):
raise
else:
print(e.MESSAGE.format(x=e.x))
- time.sleep(e.x)
+ await asyncio.sleep(e.x)
except Exception as e:
log.error(e, exc_info=True)
raise
diff --git a/pyrogram/client/methods/chats/get_dialogs.py b/pyrogram/client/methods/chats/get_dialogs.py
index 7d2f44e3..aa6ca912 100644
--- a/pyrogram/client/methods/chats/get_dialogs.py
+++ b/pyrogram/client/methods/chats/get_dialogs.py
@@ -16,8 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+import asyncio
import logging
-import time
import pyrogram
from pyrogram.api import functions, types
@@ -73,8 +73,8 @@ class GetDialogs(BaseClient):
)
)
except FloodWait as e:
- log.warning("Sleeping {}s".format(e.x))
- time.sleep(e.x)
+ log.warning("Sleeping for {}s".format(e.x))
+ await asyncio.sleep(e.x)
else:
break
diff --git a/pyrogram/client/methods/messages/get_history.py b/pyrogram/client/methods/messages/get_history.py
index ae9925eb..88e69244 100644
--- a/pyrogram/client/methods/messages/get_history.py
+++ b/pyrogram/client/methods/messages/get_history.py
@@ -16,8 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+import asyncio
import logging
-import time
from typing import Union
import pyrogram
diff --git a/pyrogram/client/methods/messages/get_messages.py b/pyrogram/client/methods/messages/get_messages.py
index 09a132b6..a7b9b751 100644
--- a/pyrogram/client/methods/messages/get_messages.py
+++ b/pyrogram/client/methods/messages/get_messages.py
@@ -16,8 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+import asyncio
import logging
-import time
from typing import Union, Iterable
import pyrogram
@@ -88,7 +88,7 @@ class GetMessages(BaseClient):
r = await self.send(rpc)
except FloodWait as e:
log.warning("Sleeping for {}s".format(e.x))
- time.sleep(e.x)
+ await asyncio.sleep(e.x)
else:
break
diff --git a/pyrogram/session/auth.py b/pyrogram/session/auth.py
index 17b22d6f..f966705f 100644
--- a/pyrogram/session/auth.py
+++ b/pyrogram/session/auth.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see .
+import asyncio
import logging
import time
from hashlib import sha1
@@ -254,7 +255,7 @@ class Auth:
else:
raise e
- time.sleep(1)
+ await asyncio.sleep(1)
continue
else:
return auth_key