mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Fix signal handler not working on Windows
This commit is contained in:
parent
64ebf979e5
commit
bce7d5b6e8
@ -159,7 +159,7 @@ class Client:
|
||||
|
||||
self.session = None
|
||||
|
||||
self.is_idle = Event()
|
||||
self.is_idle = None
|
||||
|
||||
self.updates_queue = Queue()
|
||||
self.update_queue = Queue()
|
||||
@ -472,7 +472,7 @@ class Client:
|
||||
|
||||
def signal_handler(self, *args):
|
||||
self.stop()
|
||||
self.is_idle.set()
|
||||
self.is_idle = False
|
||||
|
||||
def idle(self, stop_signals: tuple = (SIGINT, SIGTERM, SIGABRT)):
|
||||
"""Blocks the program execution until one of the signals are received,
|
||||
@ -486,7 +486,10 @@ class Client:
|
||||
for s in stop_signals:
|
||||
signal(s, self.signal_handler)
|
||||
|
||||
self.is_idle.wait()
|
||||
self.is_idle = True
|
||||
|
||||
while self.is_idle:
|
||||
time.sleep(1)
|
||||
|
||||
def set_update_handler(self, callback: callable):
|
||||
"""Use this method to set the update handler.
|
||||
|
Loading…
x
Reference in New Issue
Block a user