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