mirror of
https://github.com/borgbase/vorta
synced 2025-01-02 21:25:48 +00:00
Add QTimer to ensure background jobs are scheduled correctly. (#780)
* Add QTimer to ensure background jobs are scheduled correctly. * Exclude from App Nap to keep timer enabled. * Remove notifications for schedule changes, since we do it very often now.
This commit is contained in:
parent
227e06d228
commit
aa04d72252
3 changed files with 10 additions and 3 deletions
|
@ -68,6 +68,7 @@ app = BUNDLE(coll,
|
|||
'CFBundleDisplayName': APP_NAME,
|
||||
'CFBundleIdentifier': APP_ID_DARWIN,
|
||||
'NSHighResolutionCapable': 'True',
|
||||
'LSAppNapIsDisabled': 'True',
|
||||
'NSRequiresAquaSystemAppearance': 'False',
|
||||
'LSUIElement': '1',
|
||||
'LSMinimumSystemVersion': '10.14',
|
||||
|
|
|
@ -42,7 +42,7 @@ install_requires =
|
|||
pyqt5
|
||||
peewee
|
||||
python-dateutil
|
||||
apscheduler
|
||||
apscheduler < 4.0
|
||||
psutil
|
||||
setuptools
|
||||
secretstorage; sys_platform != 'darwin'
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
from datetime import date, timedelta
|
||||
|
||||
from PyQt5 import QtCore
|
||||
from apscheduler.schedulers.qt import QtScheduler
|
||||
from apscheduler.triggers import cron
|
||||
from vorta.borg.check import BorgCheckThread
|
||||
|
@ -15,6 +16,7 @@
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# TODO: refactor to use QtCore.QTimer directly
|
||||
class VortaScheduler(QtScheduler):
|
||||
def __init__(self, parent):
|
||||
super().__init__()
|
||||
|
@ -22,6 +24,12 @@ def __init__(self, parent):
|
|||
self.start()
|
||||
self.reload()
|
||||
|
||||
# Set timer to make sure background tasks are scheduled
|
||||
self.qt_timer = QtCore.QTimer()
|
||||
self.qt_timer.timeout.connect(self.reload)
|
||||
self.qt_timer.setInterval(45 * 60 * 1000)
|
||||
self.qt_timer.start()
|
||||
|
||||
def tr(self, *args, **kwargs):
|
||||
scope = self.__class__.__name__
|
||||
return translate(scope, *args, **kwargs)
|
||||
|
@ -51,8 +59,6 @@ def reload(self):
|
|||
minute=profile.schedule_fixed_minute)
|
||||
if self.get_job(job_id) is not None and trigger is not None:
|
||||
self.reschedule_job(job_id, trigger=trigger)
|
||||
notifier = VortaNotifications.pick()
|
||||
notifier.deliver(self.tr('Vorta Scheduler'), self.tr('Background scheduler was changed.'))
|
||||
logger.debug('Job for profile %s was rescheduled.', profile.name)
|
||||
elif trigger is not None:
|
||||
self.add_job(
|
||||
|
|
Loading…
Reference in a new issue