From deb5ce5b88e747c6a0c0194fe7a8d8f8d33c523d Mon Sep 17 00:00:00 2001 From: Vxrtrauter Date: Sun, 19 Oct 2025 03:53:52 +0200 Subject: [PATCH] fixed aria2 killing issues on settings close --- core/utils/config/settings.py | 50 +++++++++-------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/core/utils/config/settings.py b/core/utils/config/settings.py index b284f5e..6d122a5 100644 --- a/core/utils/config/settings.py +++ b/core/utils/config/settings.py @@ -1,49 +1,23 @@ from core.utils.data.state import state +from core.utils.general.shutdown import kill_aria2server from .config import create_config def restart_aria2c(): import main # had to do this because of circle import :( import signal import atexit - import time + kill_aria2server() + state.aria2process.wait() + state.aria2process = main.run_aria2server() + signal.signal(signal.SIGINT, main.keyboardinterrupthandler) + atexit.unregister(kill_aria2server) + atexit.register(kill_aria2server) - try: - main.kill_aria2server() - except Exception as e: - print(f"Warning: aria2server kill failed: {e}") - - try: - if state.aria2process: - state.aria2process.wait(timeout=3) - except Exception as e: - print(f"Warning: aria2process wait failed: {e}") - - time.sleep(0.5) - - try: - state.aria2process = main.run_aria2server() - except Exception as e: - print(f"Error: failed to restart aria2server: {e}") - return - - try: - signal.signal(signal.SIGINT, main.keyboardinterrupthandler) - atexit.unregister(main.kill_aria2server) - atexit.register(main.kill_aria2server) - except Exception as e: - print(f"Warning: signal/atexit setup failed: {e}") - -def save_settings(thread_count=None, close=lambda: None, apiurl=None, download_path=None, speed_limit=None, version=None): - if thread_count is not None: - state.aria2_threads = thread_count - if apiurl is not None: - state.api_url = apiurl - if download_path is not None: - state.download_path = download_path - if speed_limit is not None: - state.speed_limit = speed_limit - if version is not None: - state.version = version +def save_settings(thread_count, close, apiurl, download_path, speed_limit): + state.aria2_threads = thread_count + state.api_url = apiurl + state.download_path = download_path + state.speed_limit = speed_limit create_config() restart_aria2c()