From 16a2023bbd2d490f4aaa473bc9b24f01ab00f3db Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 9 Mar 2022 20:01:17 -0300 Subject: [PATCH] stop tasks before removing transport --- lbry/torrent/tracker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lbry/torrent/tracker.py b/lbry/torrent/tracker.py index 07c4ab785..5e78ed045 100644 --- a/lbry/torrent/tracker.py +++ b/lbry/torrent/tracker.py @@ -140,13 +140,13 @@ class TrackerClient: lambda request: self.on_hash(request[1], request[2]) if request[0] == 'search' else None) def stop(self): + while self.tasks: + self.tasks.popitem()[1].cancel() if self.transport is not None: self.transport.close() self.client = None self.transport = None self.EVENT_CONTROLLER.close() - while self.tasks: - self.tasks.popitem()[1].cancel() def on_hash(self, info_hash, on_announcement=None): if info_hash not in self.tasks: