mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Remove handlers lock
This commit is contained in:
parent
b04bce9dba
commit
93218a6ed7
@ -50,8 +50,6 @@ class Dispatcher:
|
||||
self.updates = Queue()
|
||||
self.groups = OrderedDict()
|
||||
|
||||
self._handler_lock = threading.Lock()
|
||||
|
||||
def start(self):
|
||||
for i in range(self.workers):
|
||||
self.workers_list.append(
|
||||
@ -73,7 +71,6 @@ class Dispatcher:
|
||||
self.workers_list.clear()
|
||||
|
||||
def add_handler(self, handler, group: int):
|
||||
with self._handler_lock:
|
||||
if group not in self.groups:
|
||||
self.groups[group] = []
|
||||
self.groups = OrderedDict(sorted(self.groups.items()))
|
||||
@ -81,14 +78,12 @@ class Dispatcher:
|
||||
self.groups[group].append(handler)
|
||||
|
||||
def remove_handler(self, handler, group: int):
|
||||
with self._handler_lock:
|
||||
if group not in self.groups:
|
||||
raise ValueError("Group {} does not exist. "
|
||||
"Handler was not removed.".format(group))
|
||||
self.groups[group].remove(handler)
|
||||
|
||||
def dispatch(self, update, users: dict = None, chats: dict = None, is_raw: bool = False):
|
||||
with self._handler_lock:
|
||||
for group in self.groups.values():
|
||||
for handler in group:
|
||||
if is_raw:
|
||||
|
Loading…
x
Reference in New Issue
Block a user