diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index b6241746..d81c3707 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -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: diff --git a/pyrogram/client/ext/syncer.py b/pyrogram/client/ext/syncer.py index c5f15c1a..88caa160 100644 --- a/pyrogram/client/ext/syncer.py +++ b/pyrogram/client/ext/syncer.py @@ -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: diff --git a/pyrogram/connection/transport/tcp/tcp.py b/pyrogram/connection/transport/tcp/tcp.py index 237c5c59..0d33fcd9 100644 --- a/pyrogram/connection/transport/tcp/tcp.py +++ b/pyrogram/connection/transport/tcp/tcp.py @@ -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()