Fixed sleep prevention process not ending if program exited using Ctrl+C or kill

This commit is contained in:
Deniz Şafak
2025-07-16 15:35:45 +03:00
parent 977b2a736c
commit f1903eb6ac
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -1,6 +1,7 @@
# 1.1.5 (pre-release) # 1.1.5 (pre-release)
- Changed the temporary directory path to user's cache directory, which is more appropriate for storing cache files and avoids issues with unintended cleanup. - Changed the temporary directory path to user's cache directory, which is more appropriate for storing cache files and avoids issues with unintended cleanup.
- Fixed the isssue where extra metadata information was not being saved to M4B files when they have no chapters, ensuring that all metadata is correctly written to the output file. - Fixed the isssue where extra metadata information was not being saved to M4B files when they have no chapters, ensuring that all metadata is correctly written to the output file.
- Fixed sleep prevention process not ending if program exited using Ctrl+C or kill.
# 1.1.4 # 1.1.4
- Fixed extra metadata information not being saved to M4B files, ensuring that all metadata is correctly written to the output file. - Fixed extra metadata information not being saved to M4B files, ensuring that all metadata is correctly written to the output file.
+9 -1
View File
@@ -3,6 +3,7 @@ import os
import sys import sys
import platform import platform
import atexit import atexit
import signal
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
from PyQt5.QtCore import qInstallMessageHandler, QtMsgType from PyQt5.QtCore import qInstallMessageHandler, QtMsgType
@@ -31,6 +32,14 @@ os.environ["MIOPEN_CONV_PRECISE_ROCM_TUNING"] = "0"
# Reset sleep states # Reset sleep states
atexit.register(prevent_sleep_end) atexit.register(prevent_sleep_end)
# Also handle signals (Ctrl+C, kill, etc.)
def _cleanup_sleep(signum, frame):
prevent_sleep_end()
sys.exit(0)
signal.signal(signal.SIGINT, _cleanup_sleep)
signal.signal(signal.SIGTERM, _cleanup_sleep)
# Ensure sys.stdout and sys.stderr are valid in GUI mode # Ensure sys.stdout and sys.stderr are valid in GUI mode
if sys.stdout is None: if sys.stdout is None:
sys.stdout = open(os.devnull, "w") sys.stdout = open(os.devnull, "w")
@@ -41,7 +50,6 @@ if sys.stderr is None:
if platform.system() == "Darwin" and platform.processor() == "arm": if platform.system() == "Darwin" and platform.processor() == "arm":
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
# Custom message handler to filter out specific Qt warnings # Custom message handler to filter out specific Qt warnings
def qt_message_handler(mode, context, message): def qt_message_handler(mode, context, message):
if "Wayland does not support QWindow::requestActivate()" in message: if "Wayland does not support QWindow::requestActivate()" in message: