mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
fixed aria2 killing issues on settings close
This commit is contained in:
@@ -1,49 +1,23 @@
|
|||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
|
from core.utils.general.shutdown import kill_aria2server
|
||||||
from .config import create_config
|
from .config import create_config
|
||||||
|
|
||||||
def restart_aria2c():
|
def restart_aria2c():
|
||||||
import main # had to do this because of circle import :(
|
import main # had to do this because of circle import :(
|
||||||
import signal
|
import signal
|
||||||
import atexit
|
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:
|
def save_settings(thread_count, close, apiurl, download_path, speed_limit):
|
||||||
main.kill_aria2server()
|
state.aria2_threads = thread_count
|
||||||
except Exception as e:
|
state.api_url = apiurl
|
||||||
print(f"Warning: aria2server kill failed: {e}")
|
state.download_path = download_path
|
||||||
|
state.speed_limit = speed_limit
|
||||||
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
|
|
||||||
|
|
||||||
create_config()
|
create_config()
|
||||||
restart_aria2c()
|
restart_aria2c()
|
||||||
|
|||||||
Reference in New Issue
Block a user