From 6da15b266d894e02a54ece61d27bedb54c88c228 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 17 Jun 2018 18:34:10 +0200 Subject: [PATCH] Await tasks before stopping the session --- pyrogram/session/session.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index 60276947..f06264c0 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -186,11 +186,11 @@ class Session: self.connection.close() - await self.recv_task + if self.recv_task: + await self.recv_task - self.recv_queue.put_nowait(None) - - await self.net_worker_task + if self.net_worker_task: + await self.net_worker_task for i in self.results.values(): i.event.set()