From 09e0345868d3d28a46df6a0e79463199c260e8f9 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 18 Oct 2018 21:18:22 +0200 Subject: [PATCH] Small dispatcher clean ups --- pyrogram/client/dispatcher/dispatcher.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pyrogram/client/dispatcher/dispatcher.py b/pyrogram/client/dispatcher/dispatcher.py index 2989d9fa..cbfb59e4 100644 --- a/pyrogram/client/dispatcher/dispatcher.py +++ b/pyrogram/client/dispatcher/dispatcher.py @@ -50,6 +50,7 @@ class Dispatcher: def __init__(self, client, workers): self.client = client self.workers = workers + self.workers_list = [] self.updates = Queue() self.groups = OrderedDict() @@ -69,8 +70,8 @@ class Dispatcher: for _ in range(self.workers): self.updates.put(None) - for i in self.workers_list: - i.join() + for worker in self.workers_list: + worker.join() self.workers_list.clear() @@ -83,8 +84,8 @@ class Dispatcher: def remove_handler(self, handler, group: int): if group not in self.groups: - raise ValueError("Group {} does not exist. " - "Handler was not removed.".format(group)) + raise ValueError("Group {} does not exist. Handler was not removed.".format(group)) + self.groups[group].remove(handler) def update_worker(self): @@ -108,8 +109,7 @@ class Dispatcher: if isinstance(update.message, types.MessageEmpty): continue - message = utils.parse_messages(self.client, update.message, users, chats) - update = message, MessageHandler + update = utils.parse_messages(self.client, update.message, users, chats), MessageHandler elif isinstance(update, Dispatcher.DELETE_MESSAGE_UPDATES): deleted_messages = utils.parse_deleted_messages(