2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Move signal handler inside idle

This commit is contained in:
Dan 2018-06-23 15:45:48 +02:00
parent 2b94f46728
commit 7f11f85c8f

View File

@ -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