mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-31 22:35:36 +00:00
Fix sleep method calls in asyncio: time.sleep -> asyncio.sleep
This commit is contained in:
@@ -48,7 +48,6 @@ from pyrogram.api.errors import (
|
|||||||
VolumeLocNotFound, UserMigrate, FileIdInvalid, ChannelPrivate, PhoneNumberOccupied,
|
VolumeLocNotFound, UserMigrate, FileIdInvalid, ChannelPrivate, PhoneNumberOccupied,
|
||||||
PasswordRecoveryNa, PasswordEmpty
|
PasswordRecoveryNa, PasswordEmpty
|
||||||
)
|
)
|
||||||
from pyrogram.client.handlers import DisconnectHandler
|
|
||||||
from pyrogram.client.handlers.handler import Handler
|
from pyrogram.client.handlers.handler import Handler
|
||||||
from pyrogram.client.methods.password.utils import compute_check
|
from pyrogram.client.methods.password.utils import compute_check
|
||||||
from pyrogram.crypto import AES
|
from pyrogram.crypto import AES
|
||||||
@@ -571,7 +570,7 @@ class Client(Methods, BaseClient):
|
|||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
print(e.MESSAGE.format(x=e.x))
|
print(e.MESSAGE.format(x=e.x))
|
||||||
time.sleep(e.x)
|
await asyncio.sleep(e.x)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e, exc_info=True)
|
log.error(e, exc_info=True)
|
||||||
raise
|
raise
|
||||||
@@ -707,7 +706,7 @@ class Client(Methods, BaseClient):
|
|||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
print(e.MESSAGE.format(x=e.x))
|
print(e.MESSAGE.format(x=e.x))
|
||||||
time.sleep(e.x)
|
await asyncio.sleep(e.x)
|
||||||
self.password = None
|
self.password = None
|
||||||
self.recovery_code = None
|
self.recovery_code = None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -721,7 +720,7 @@ class Client(Methods, BaseClient):
|
|||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
print(e.MESSAGE.format(x=e.x))
|
print(e.MESSAGE.format(x=e.x))
|
||||||
time.sleep(e.x)
|
await asyncio.sleep(e.x)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e, exc_info=True)
|
log.error(e, exc_info=True)
|
||||||
raise
|
raise
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import functions, types
|
from pyrogram.api import functions, types
|
||||||
@@ -73,8 +73,8 @@ class GetDialogs(BaseClient):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
except FloodWait as e:
|
except FloodWait as e:
|
||||||
log.warning("Sleeping {}s".format(e.x))
|
log.warning("Sleeping for {}s".format(e.x))
|
||||||
time.sleep(e.x)
|
await asyncio.sleep(e.x)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
from typing import Union, Iterable
|
from typing import Union, Iterable
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
@@ -88,7 +88,7 @@ class GetMessages(BaseClient):
|
|||||||
r = await self.send(rpc)
|
r = await self.send(rpc)
|
||||||
except FloodWait as e:
|
except FloodWait as e:
|
||||||
log.warning("Sleeping for {}s".format(e.x))
|
log.warning("Sleeping for {}s".format(e.x))
|
||||||
time.sleep(e.x)
|
await asyncio.sleep(e.x)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
@@ -254,7 +255,7 @@ class Auth:
|
|||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
time.sleep(1)
|
await asyncio.sleep(1)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
return auth_key
|
return auth_key
|
||||||
|
Reference in New Issue
Block a user