From 5bc775dfb9ea9c55e4e3cb867ef1c0563a25e909 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 17 Jul 2014 22:57:35 -0700 Subject: [PATCH] Fix for threading issues with backlogs and whitelist/blacklist issues for anime shows. --- sickbeard/generic_queue.py | 10 +++----- sickbeard/search_queue.py | 25 ++++++++++++------- sickbeard/show_queue.py | 4 ++-- sickbeard/webserve.py | 49 +++++++++++++++++++------------------- 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/sickbeard/generic_queue.py b/sickbeard/generic_queue.py index 9ec730f3..09266ceb 100644 --- a/sickbeard/generic_queue.py +++ b/sickbeard/generic_queue.py @@ -86,7 +86,7 @@ class GenericQueue(object): self.queue.sort(cmp=sorter) - queueItem = self.queue[0] + queueItem = self.queue.pop(0) if queueItem.priority < self.min_priority: return @@ -97,9 +97,7 @@ class GenericQueue(object): self.currentItem = queueItem - # take it out of the queue - del self.queue[0] - + queueItem.join() class QueueItem(threading.Thread): def __init__(self, name, action_id=0): @@ -116,10 +114,8 @@ class QueueItem(threading.Thread): """Implementing classes should call this""" self.inProgress = True - self.alive = True def finish(self): """Implementing Classes should call this""" - self.inProgress = False - self.alive = False \ No newline at end of file + self.inProgress = False \ No newline at end of file diff --git a/sickbeard/search_queue.py b/sickbeard/search_queue.py index 94f33390..60825de8 100644 --- a/sickbeard/search_queue.py +++ b/sickbeard/search_queue.py @@ -88,6 +88,7 @@ class SearchQueue(generic_queue.GenericQueue): else: logger.log(u"Not adding item, it's already in the queue", logger.DEBUG) + class DailySearchQueueItem(generic_queue.QueueItem): def __init__(self, show, segment): generic_queue.QueueItem.__init__(self, 'Daily Search', DAILY_SEARCH) @@ -123,6 +124,9 @@ class DailySearchQueueItem(generic_queue.QueueItem): except Exception: logger.log(traceback.format_exc(), logger.DEBUG) + self.finish() + + class ManualSearchQueueItem(generic_queue.QueueItem): def __init__(self, show, segment): generic_queue.QueueItem.__init__(self, 'Manual Search', MANUAL_SEARCH) @@ -159,12 +163,16 @@ class ManualSearchQueueItem(generic_queue.QueueItem): except Exception: logger.log(traceback.format_exc(), logger.DEBUG) + self.finish() + def finish(self): # don't let this linger if something goes wrong - if self.success == None: + if self.success is None: self.success = False + generic_queue.QueueItem.finish(self) + class BacklogQueueItem(generic_queue.QueueItem): def __init__(self, show, segment): generic_queue.QueueItem.__init__(self, 'Backlog', BACKLOG_SEARCH) @@ -177,13 +185,13 @@ class BacklogQueueItem(generic_queue.QueueItem): def run(self): generic_queue.QueueItem.run(self) - for season in self.segment: - sickbeard.searchBacklog.BacklogSearcher.currentSearchInfo = { - 'title': self.show.name + " Season " + str(season)} + try: + for season in self.segment: + sickbeard.searchBacklog.BacklogSearcher.currentSearchInfo = { + 'title': self.show.name + " Season " + str(season)} - wantedEps = self.segment[season] + wantedEps = self.segment[season] - try: logger.log("Beginning backlog search for [" + self.show.name + "]") searchResult = search.searchProviders(self.show, season, wantedEps, False) @@ -201,9 +209,8 @@ class BacklogQueueItem(generic_queue.QueueItem): else: logger.log(u"No needed episodes found during backlog search for [" + self.show.name + "]") - - except Exception: - logger.log(traceback.format_exc(), logger.DEBUG) + except Exception: + logger.log(traceback.format_exc(), logger.DEBUG) self.finish() diff --git a/sickbeard/show_queue.py b/sickbeard/show_queue.py index f1641c2f..eec4b357 100644 --- a/sickbeard/show_queue.py +++ b/sickbeard/show_queue.py @@ -423,8 +423,8 @@ class QueueItemRefresh(ShowQueueItem): self.show.refreshDir() self.show.writeMetadata() - if self.force: - self.show.updateMetadata() + #if self.force: + # self.show.updateMetadata() self.show.populateCache() # Load XEM data to DB for show diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 00940669..dce815a3 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -3659,34 +3659,33 @@ class Home(MainHandler): t = PageTemplate(headers=self.request.headers, file="editShow.tmpl") t.submenu = HomeMenu() + if showObj.is_anime: + bwl = BlackAndWhiteList(showObj.indexerid) + + t.whiteWords = "" + if "global" in bwl.whiteDict: + t.whiteWords = ", ".join(bwl.whiteDict["global"]) + + t.blackWords = "" + if "global" in bwl.blackDict: + t.blackWords = ", ".join(bwl.blackDict["global"]) + + t.whitelist = [] + if bwl.whiteDict.has_key("release_group"): + t.whitelist = bwl.whiteDict["release_group"] + + t.blacklist = [] + if bwl.blackDict.has_key("release_group"): + t.blacklist = bwl.blackDict["release_group"] + + t.groups = [] + if helpers.set_up_anidb_connection(): + anime = adba.Anime(sickbeard.ADBA_CONNECTION, name=showObj.name) + t.groups = anime.get_groups() + with showObj.lock: t.show = showObj - if showObj.is_anime: - t.whiteWords = "" - t.whitelist = [] - - t.blackWords = "" - t.blacklist = [] - - t.groups = [] - - bwl = BlackAndWhiteList(showObj.indexerid) - if "global" in bwl.whiteDict: - t.whiteWords = ", ".join(bwl.whiteDict["global"]) - if "global" in bwl.blackDict: - t.blackWords = ", ".join(bwl.blackDict["global"]) - - if bwl.whiteDict.has_key("release_group"): - t.whitelist = bwl.whiteDict["release_group"] - - if bwl.blackDict.has_key("release_group"): - t.blacklist = bwl.blackDict["release_group"] - - if helpers.set_up_anidb_connection(): - anime = adba.Anime(sickbeard.ADBA_CONNECTION, name=showObj.name) - t.groups = anime.get_groups() - t.scene_exceptions = get_scene_exceptions(showObj.indexerid) return _munge(t)