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