mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
fixed shutdown issues, added shutdown event for download notification
This commit is contained in:
@@ -48,8 +48,8 @@ def dlprogress():
|
|||||||
except:
|
except:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def send_notification():
|
def send_notification(shutdown_event):
|
||||||
while True:
|
while not shutdown_event.is_set():
|
||||||
try:
|
try:
|
||||||
for download in state.aria2.get_downloads():
|
for download in state.aria2.get_downloads():
|
||||||
if dlprogress() == 100:
|
if dlprogress() == 100:
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import sys
|
|||||||
|
|
||||||
# Debug Output
|
# Debug Output
|
||||||
state.debug = True
|
state.debug = True
|
||||||
|
shutdown_event = threading.Event()
|
||||||
|
|
||||||
def run_gui():
|
def run_gui():
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
@@ -38,6 +39,7 @@ def kill_aria2server():
|
|||||||
|
|
||||||
|
|
||||||
def keyboardinterrupthandler(signum, frame):
|
def keyboardinterrupthandler(signum, frame):
|
||||||
|
shutdown_event.set()
|
||||||
kill_aria2server()
|
kill_aria2server()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ if __name__ == "__main__":
|
|||||||
state.aria2process = run_aria2server()
|
state.aria2process = run_aria2server()
|
||||||
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
||||||
atexit.register(kill_aria2server)
|
atexit.register(kill_aria2server)
|
||||||
run_thread(threading.Thread(target=send_notification))
|
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
|
||||||
if state.debug:
|
if state.debug:
|
||||||
print("Launching GUI")
|
print("Launching GUI")
|
||||||
run_gui()
|
run_gui()
|
||||||
|
|||||||
Reference in New Issue
Block a user