mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-17 13:21:52 +00:00
Replace "with await" with "async with"
This commit is contained in:
parent
b3d6b41ca8
commit
9bd9d7797b
@ -1555,7 +1555,7 @@ class Client(Methods, BaseClient):
|
||||
is_big: bool,
|
||||
progress: callable,
|
||||
progress_args: tuple = ()) -> str:
|
||||
with await self.media_sessions_lock:
|
||||
async with self.media_sessions_lock:
|
||||
session = self.media_sessions.get(dc_id, None)
|
||||
|
||||
if session is None:
|
||||
@ -1670,7 +1670,7 @@ class Client(Methods, BaseClient):
|
||||
)
|
||||
|
||||
elif isinstance(r, types.upload.FileCdnRedirect):
|
||||
with await self.media_sessions_lock:
|
||||
async with self.media_sessions_lock:
|
||||
cdn_session = self.media_sessions.get(r.dc_id, None)
|
||||
|
||||
if cdn_session is None:
|
||||
|
@ -44,7 +44,7 @@ class Syncer:
|
||||
if cls.lock is None:
|
||||
cls.lock = asyncio.Lock()
|
||||
|
||||
with await cls.lock:
|
||||
async with cls.lock:
|
||||
cls.sync(client)
|
||||
|
||||
cls.clients[id(client)] = client
|
||||
@ -54,7 +54,7 @@ class Syncer:
|
||||
|
||||
@classmethod
|
||||
async def remove(cls, client):
|
||||
with await cls.lock:
|
||||
async with cls.lock:
|
||||
cls.sync(client)
|
||||
|
||||
del cls.clients[id(client)]
|
||||
@ -77,7 +77,7 @@ class Syncer:
|
||||
try:
|
||||
await asyncio.wait_for(cls.event.wait(), cls.INTERVAL)
|
||||
except asyncio.TimeoutError:
|
||||
with await cls.lock:
|
||||
async with cls.lock:
|
||||
for client in cls.clients.values():
|
||||
cls.sync(client)
|
||||
else:
|
||||
|
@ -92,7 +92,7 @@ class TCP:
|
||||
self.socket.close()
|
||||
|
||||
async def send(self, data: bytes):
|
||||
with await self.lock:
|
||||
async with self.lock:
|
||||
self.writer.write(data)
|
||||
await self.writer.drain()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user