You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-26 21:53:54 +01:00
make it safer
This commit is contained in:
@@ -44,6 +44,7 @@ logger = log95.log95("radioPlayer", logger_level)
|
|||||||
|
|
||||||
exit_pending = False
|
exit_pending = False
|
||||||
intr_time = 0
|
intr_time = 0
|
||||||
|
exit_lock = threading.Lock()
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Process:
|
class Process:
|
||||||
@@ -105,15 +106,16 @@ procman = ProcessManager()
|
|||||||
|
|
||||||
def handle_sigint(signum, frame):
|
def handle_sigint(signum, frame):
|
||||||
global exit_pending, intr_time
|
global exit_pending, intr_time
|
||||||
logger.info("Received SIGINT")
|
with exit_lock:
|
||||||
if (time.time() - intr_time) > 5:
|
logger.info("Received SIGINT")
|
||||||
intr_time = time.time()
|
if (time.time() - intr_time) > 5:
|
||||||
logger.info("Will quit on song end.")
|
intr_time = time.time()
|
||||||
exit_pending = True
|
logger.info("Will quit on song end.")
|
||||||
else:
|
exit_pending = True
|
||||||
logger.warning("Force-Quit pending")
|
else:
|
||||||
procman.stop_all()
|
logger.warning("Force-Quit pending")
|
||||||
exit(0)
|
procman.stop_all()
|
||||||
|
exit(0)
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, handle_sigint)
|
signal.signal(signal.SIGINT, handle_sigint)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user