2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-30 22:05:28 +00:00

Fix sleep method calls in asyncio: time.sleep -> asyncio.sleep

This commit is contained in:
Dan
2019-02-04 18:34:58 +01:00
parent 2b8e4857dc
commit 4eb26c5b92
5 changed files with 11 additions and 11 deletions

View File

@@ -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

View File

@@ -16,8 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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

View File

@@ -16,8 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import asyncio
import logging
import time
from typing import Union
import pyrogram

View File

@@ -16,8 +16,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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

View File

@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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