From 7f11f85c8fd57c972043547d3f760a810597ec98 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 23 Jun 2018 15:45:48 +0200 Subject: [PATCH] Move signal handler inside idle --- pyrogram/client/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 6db22fa4..24bf09eb 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -280,9 +280,6 @@ class Client(Methods, BaseClient): self.is_started = False self.session.stop() - def signal_handler(self, *args): - self.is_idle = False - def idle(self, stop_signals: tuple = (SIGINT, SIGTERM, SIGABRT)): """Blocks the program execution until one of the signals are received, then gently stop the Client by closing the underlying connection. @@ -292,8 +289,11 @@ class Client(Methods, BaseClient): Iterable containing signals the signal handler will listen to. Defaults to (SIGINT, SIGTERM, SIGABRT). """ + def signal_handler(*args): + self.is_idle = False + for s in stop_signals: - signal(s, self.signal_handler) + signal(s, signal_handler) self.is_idle = True