mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
fix: implement forced exit on shutdown and enhance shutdown handling
This commit is contained in:
@@ -725,6 +725,8 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
def closeEvent(self, event: QCloseEvent):
|
def closeEvent(self, event: QCloseEvent):
|
||||||
closehelper()
|
closehelper()
|
||||||
event.accept()
|
event.accept()
|
||||||
|
from core.utils.general.shutdown import force_exit
|
||||||
|
force_exit()
|
||||||
|
|
||||||
def eventFilter(self, obj, event):
|
def eventFilter(self, obj, event):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import threading
|
|||||||
import libtorrent as lt
|
import libtorrent as lt
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
|
from core.utils.general.shutdown import shutdown_event
|
||||||
|
|
||||||
|
|
||||||
global loop_running
|
global loop_running
|
||||||
@@ -116,9 +117,12 @@ def dl_status_loop():
|
|||||||
loop_running = False
|
loop_running = False
|
||||||
return
|
return
|
||||||
|
|
||||||
while state.active_downloads:
|
while state.active_downloads and not shutdown_event.is_set():
|
||||||
for magnet_uri, magnetdl in list(state.active_downloads.items()):
|
for magnet_uri, magnetdl in list(state.active_downloads.items()):
|
||||||
status = magnetdl.status()
|
try:
|
||||||
|
status = magnetdl.status()
|
||||||
|
except RuntimeError:
|
||||||
|
continue
|
||||||
|
|
||||||
if status.state == lt.torrent_status.seeding and magnet_uri not in completed_set:
|
if status.state == lt.torrent_status.seeding and magnet_uri not in completed_set:
|
||||||
consoleLog(f"Download completed: {status.name}")
|
consoleLog(f"Download completed: {status.name}")
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import threading
|
import threading
|
||||||
from core.network.libtorrent_misc import cleanup_session
|
import os
|
||||||
from core.utils.general.wrappers import run_thread
|
|
||||||
|
|
||||||
shutdown_event = threading.Event()
|
shutdown_event = threading.Event()
|
||||||
|
|
||||||
def closehelper():
|
def closehelper():
|
||||||
run_thread(threading.Thread(target=cleanup_session))
|
|
||||||
shutdown_event.set()
|
shutdown_event.set()
|
||||||
|
|
||||||
|
def force_exit():
|
||||||
|
os._exit(0)
|
||||||
+2
-1
@@ -33,7 +33,8 @@ def run_gui():
|
|||||||
|
|
||||||
def keyboardinterrupthandler(signum, frame):
|
def keyboardinterrupthandler(signum, frame):
|
||||||
closehelper()
|
closehelper()
|
||||||
windowCloseHelper()
|
from core.utils.general.shutdown import force_exit
|
||||||
|
force_exit()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
|
|||||||
Reference in New Issue
Block a user