File tree Expand file tree Collapse file tree
pyrogram/methods/utilities Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818
1919import asyncio
2020import logging
21- from signal import signal , SIGINT , SIGTERM , SIGABRT
21+ import signal
22+ from signal import signal as signal_fn , SIGINT , SIGTERM , SIGABRT
2223
2324log = logging .getLogger (__name__ )
2425
2526is_idling = False
2627
28+ # Signal number to name
29+ signals = {
30+ k : v for v , k in signal .__dict__ .items ()
31+ if v .startswith ("SIG" ) and not v .startswith ("SIG_" )
32+ }
33+
2734
2835async def idle ():
2936 """Block the main script execution until a signal is received.
@@ -65,14 +72,14 @@ async def idle():
6572 """
6673 global is_idling
6774
68- def signal_handler (_ , __ ):
75+ def signal_handler (signum , __ ):
6976 global is_idling
7077
71- logging .info ("Stop signal received ({}). Exiting..." . format ( _ ) )
78+ logging .info (f "Stop signal received ({ signals [ signum ] } ). Exiting..." )
7279 is_idling = False
7380
7481 for s in (SIGINT , SIGTERM , SIGABRT ):
75- signal (s , signal_handler )
82+ signal_fn (s , signal_handler )
7683
7784 is_idling = True
7885
You can’t perform that action at this time.
0 commit comments