Commit ae00748d authored by echel0n's avatar echel0n

Updater now waits for show queue to finish before updating.

parent 34aa88cd
# Changelog
- * 3176978 - 2018-11-12: Refactored show object class, cleaned up naming conventions for functions.
- * ebe6d3d - 2018-11-12: Updater now waits for show queue to finish before updating.
- * 34aa88c - 2018-11-12: Refactored show object class, cleaned up naming conventions for functions.
- * 753625d - 2018-11-12: Refactored queue current item property to always represent current running task.
- * 8bd128e - 2018-11-11: Release v9.4.30
- * 90fdbb1 - 2018-11-11: Pre-Release v9.4.30.dev1
......
......@@ -473,7 +473,7 @@ class Core(object):
self.wserver.start()
# fire off startup events
self.event_queue.fire_event(self.version_updater.run)
self.event_queue.fire_event(self.version_updater.run, force=True)
self.event_queue.fire_event(self.tz_updater.run)
# start ioloop
......
......@@ -120,18 +120,22 @@ class srQueue(threading.Thread):
self._queue.put((item.priority, time.time(), item), *args, **kwargs)
return item
@property
def is_busy(self):
return bool(len([x for x in self._current_items if x.isAlive()]))
@property
def is_paused(self):
return self.min_priority == srQueuePriorities.PAUSED
def pause(self):
"""Pauses this queue"""
sickrage.app.log.info("Pausing queue")
sickrage.app.log.info("Pausing {}".format(self.name))
self.min_priority = srQueuePriorities.PAUSED
def unpause(self):
"""Unpauses this queue"""
sickrage.app.log.info("Unpausing queue")
sickrage.app.log.info("Un-pausing {}".format(self.name))
self.min_priority = srQueuePriorities.EXTREME
def shutdown(self):
......
......@@ -17,6 +17,8 @@
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from functools import partial
from sickrage.core.queues import srQueue, srQueueItem
......@@ -24,8 +26,8 @@ class EventQueue(srQueue):
def __init__(self):
srQueue.__init__(self, "EVENTQUEUE")
def fire_event(self, event, force=False):
return self.put(EventQueueItem(event))
def fire_event(self, event, **kwargs):
return self.put(EventQueueItem(event, **kwargs))
class EventQueueItem(srQueueItem):
......@@ -33,9 +35,9 @@ class EventQueueItem(srQueueItem):
Represents an event in the queue waiting to be executed
"""
def __init__(self, event):
def __init__(self, event, **kwargs):
super(EventQueueItem, self).__init__('Firing Event')
self.event = event
self.event = partial(event, **kwargs)
def run(self):
self.event()
......@@ -43,10 +43,6 @@ class ShowQueue(srQueue):
def __init__(self):
srQueue.__init__(self, "SHOWQUEUE")
@property
def is_busy(self):
return bool(len(self._get_queue_items()))
@property
def loading_show_list(self):
return self._get_loading_show_list()
......
......@@ -28,6 +28,7 @@ import subprocess
import sys
import tarfile
import threading
from time import sleep
import sickrage
from sickrage.core.helpers import backupSR
......@@ -96,14 +97,17 @@ class VersionUpdater(object):
@staticmethod
def safe_to_update():
if sickrage.app.show_queue.is_busy:
sickrage.app.log.debug("We can't proceed with updating, show queue is busy")
return False
if sickrage.app.auto_postprocessor.amActive:
sickrage.app.log.debug("We can't proceed with updating, post-processor is running")
return False
sickrage.app.show_queue.pause()
sickrage.app.log.debug("Waiting for show queue jobs to finish")
while sickrage.app.show_queue.is_busy:
sleep(1)
return True
@staticmethod
def find_install_type():
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment