From 33c417942c8bf61d49adb1b2790aa9519613acdb Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 29 Apr 2018 20:20:34 +0200 Subject: [PATCH] Clear thread lists when stopping. Related to #62 --- pyrogram/client/client.py | 4 ++++ pyrogram/client/dispatcher/dispatcher.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index b52d0d25..35124c0f 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -385,12 +385,16 @@ class Client: for i in self.updates_workers_list: i.join() + self.updates_workers_list.clear() + for _ in range(self.DOWNLOAD_WORKERS): self.download_queue.put(None) for i in self.download_workers_list: i.join() + self.download_workers_list.clear() + self.dispatcher.stop() self.is_started = False diff --git a/pyrogram/client/dispatcher/dispatcher.py b/pyrogram/client/dispatcher/dispatcher.py index a62d0fab..15e6ccd1 100644 --- a/pyrogram/client/dispatcher/dispatcher.py +++ b/pyrogram/client/dispatcher/dispatcher.py @@ -68,6 +68,8 @@ class Dispatcher: for i in self.workers_list: i.join() + self.workers_list.clear() + def add_handler(self, handler, group: int): if group not in self.groups: self.groups[group] = []