mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
Refactor: enhance AppDaemons with QThread for improved background task management
This commit is contained in:
+6
-2
@@ -14,7 +14,7 @@ from utils.config.config import read_config
|
|||||||
from PySide6.QtGui import QAction, QPixmap
|
from PySide6.QtGui import QAction, QPixmap
|
||||||
from utils.logging.logs import consoleLog
|
from utils.logging.logs import consoleLog
|
||||||
from interface.gui import MainWindow
|
from interface.gui import MainWindow
|
||||||
from PySide6.QtCore import Qt, QObject
|
from PySide6.QtCore import Qt, QObject, QThread
|
||||||
from utils.data.state import state
|
from utils.data.state import state
|
||||||
from PySide6 import QtWidgets
|
from PySide6 import QtWidgets
|
||||||
import qdarktheme
|
import qdarktheme
|
||||||
@@ -142,8 +142,12 @@ def main():
|
|||||||
init_interfaces()
|
init_interfaces()
|
||||||
consoleLog(f"Current Bound: {state.bound_interface}")
|
consoleLog(f"Current Bound: {state.bound_interface}")
|
||||||
# Start background daemon threads
|
# Start background daemon threads
|
||||||
|
app._daemon_thread = QThread()
|
||||||
app._daemons = AppDaemons()
|
app._daemons = AppDaemons()
|
||||||
app._daemons.start_all()
|
app._daemons.moveToThread(app._daemon_thread)
|
||||||
|
app._daemon_thread.started.connect(app._daemons.start_all)
|
||||||
|
app.aboutToQuit.connect(app._daemon_thread.quit)
|
||||||
|
app._daemon_thread.start()
|
||||||
# Start background non-daemon threads
|
# Start background non-daemon threads
|
||||||
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
|
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
|
||||||
run_thread(threading.Thread(target=check_downloads, args=(downloads,)))
|
run_thread(threading.Thread(target=check_downloads, args=(downloads,)))
|
||||||
|
|||||||
@@ -28,15 +28,17 @@ class AppDaemons(QObject):
|
|||||||
self.updated_magnets = set()
|
self.updated_magnets = set()
|
||||||
|
|
||||||
# Create Timers
|
# Create Timers
|
||||||
self.deleted_files_timer = QTimer()
|
self.deleted_files_timer = QTimer(self)
|
||||||
self.completed_downloads_timer = QTimer()
|
self.completed_downloads_timer = QTimer(self)
|
||||||
|
|
||||||
# Connect Timer Signals
|
# Connect Timer Signals
|
||||||
self.deleted_files_timer.timeout.connect(self.check_deleted_files)
|
self.deleted_files_timer.timeout.connect(self.check_deleted_files)
|
||||||
self.completed_downloads_timer.timeout.connect(self.check_completed_downloads)
|
self.completed_downloads_timer.timeout.connect(self.check_completed_downloads)
|
||||||
|
|
||||||
def start_all(self):
|
def start_all(self):
|
||||||
self.deleted_files_timer.start(5000)
|
consoleLog("Starting Timer: deleted_files")
|
||||||
|
self.deleted_files_timer.start(2000)
|
||||||
|
consoleLog("Starting Timer: completed_downloads")
|
||||||
self.completed_downloads_timer.start(5000)
|
self.completed_downloads_timer.start(5000)
|
||||||
|
|
||||||
def check_deleted_files(self):
|
def check_deleted_files(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user