From b3d6b41ca8fda79c60b43d5dfb214ab0fa20a8df Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 5 Jun 2019 11:28:29 +0200 Subject: [PATCH] Fix Syncer not creating Event and Lock objects inside the current loop --- pyrogram/client/ext/syncer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/ext/syncer.py b/pyrogram/client/ext/syncer.py index a9fc4221..c5f15c1a 100644 --- a/pyrogram/client/ext/syncer.py +++ b/pyrogram/client/ext/syncer.py @@ -33,11 +33,17 @@ class Syncer: INTERVAL = 20 clients = {} - event = asyncio.Event() - lock = asyncio.Lock() + event = None + lock = None @classmethod async def add(cls, client): + if cls.event is None: + cls.event = asyncio.Event() + + if cls.lock is None: + cls.lock = asyncio.Lock() + with await cls.lock: cls.sync(client)