mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
fix aria2 process killing completely (cross-platform)
This commit is contained in:
@@ -1,14 +1,27 @@
|
|||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
import threading
|
import threading
|
||||||
|
import psutil
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
shutdown_event = threading.Event()
|
shutdown_event = threading.Event()
|
||||||
|
|
||||||
def kill_aria2server():
|
def kill_aria2server():
|
||||||
|
if sys.platform.startswith("win"):
|
||||||
|
process = "aria2c.exe"
|
||||||
|
else:
|
||||||
|
process = "aria2c"
|
||||||
|
|
||||||
if state.aria2process:
|
if state.aria2process:
|
||||||
state.aria2process.kill()
|
state.aria2process.kill()
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("\nKilled Aria2")
|
print("Killed Aria2")
|
||||||
|
|
||||||
|
for proc in psutil.process_iter():
|
||||||
|
if proc.name() == process:
|
||||||
|
proc.kill()
|
||||||
|
if state.debug:
|
||||||
|
print("Killed Aria2c")
|
||||||
|
|
||||||
|
|
||||||
def closehelper():
|
def closehelper():
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ def download_selected(item, posts, post_titles):
|
|||||||
print(f"network {item.text()}")
|
print(f"network {item.text()}")
|
||||||
run_thread(threading.Thread(target=run_download, args=(item.text(), posts, post_titles)))
|
run_thread(threading.Thread(target=run_download, args=(item.text(), posts, post_titles)))
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("No item selected for download.")
|
print("No item selected for download.")
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ if __name__ == "__main__":
|
|||||||
print("Starting Aria2 Server")
|
print("Starting Aria2 Server")
|
||||||
state.aria2process = run_aria2server()
|
state.aria2process = run_aria2server()
|
||||||
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
||||||
atexit.register(kill_aria2server)
|
|
||||||
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
|
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("Launching GUI")
|
print("Launching GUI")
|
||||||
|
|||||||
@@ -7,3 +7,4 @@ pyinstaller==6.15.0
|
|||||||
pyqtdarktheme==0.1.7
|
pyqtdarktheme==0.1.7
|
||||||
aiohttp==3.13.0
|
aiohttp==3.13.0
|
||||||
plyer==2.1.0
|
plyer==2.1.0
|
||||||
|
psutil==7.1.0
|
||||||
Reference in New Issue
Block a user