mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Moved show season/episode cache to outside of the show class and turned it into a global to avoid circular ref that may memory leak.
This commit is contained in:
parent
df7c3f4aff
commit
89ad4bccc3
4 changed files with 18 additions and 18 deletions
|
@ -208,9 +208,6 @@ class DBConnection(object):
|
|||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.close()
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ from sickbeard import logger
|
|||
from sickbeard import encodingKludge as ek
|
||||
from sickbeard.exceptions import ex
|
||||
from sickbeard.show_name_helpers import allPossibleShowNames
|
||||
from sickbeard import tv
|
||||
|
||||
from lib.tmdb_api.tmdb_api import TMDB
|
||||
|
||||
|
@ -337,7 +338,7 @@ class GenericMetadata():
|
|||
def create_season_posters(self, show_obj):
|
||||
if self.season_posters and show_obj:
|
||||
result = []
|
||||
for season, episodes in show_obj.episodes.iteritems(): # @UnusedVariable
|
||||
for season, episodes in tv.episodeCache.iteritems(): # @UnusedVariable
|
||||
if not self._has_season_poster(show_obj, season):
|
||||
logger.log(u"Metadata provider " + self.name + " creating season posters for " + show_obj.name,
|
||||
logger.DEBUG)
|
||||
|
@ -348,7 +349,7 @@ class GenericMetadata():
|
|||
def create_season_banners(self, show_obj):
|
||||
if self.season_banners and show_obj:
|
||||
result = []
|
||||
for season, episodes in show_obj.episodes.iteritems(): # @UnusedVariable
|
||||
for season, episodes in tv.episodeCache.iteritems(): # @UnusedVariable
|
||||
if not self._has_season_banner(show_obj, season):
|
||||
logger.log(u"Metadata provider " + self.name + " creating season banners for " + show_obj.name,
|
||||
logger.DEBUG)
|
||||
|
|
|
@ -24,6 +24,7 @@ import threading
|
|||
import re
|
||||
import glob
|
||||
import traceback
|
||||
import weakref
|
||||
|
||||
import sickbeard
|
||||
|
||||
|
@ -52,7 +53,7 @@ from common import DOWNLOADED, SNATCHED, SNATCHED_PROPER, SNATCHED_BEST, ARCHIVE
|
|||
from common import NAMING_DUPLICATE, NAMING_EXTEND, NAMING_LIMITED_EXTEND, NAMING_SEPARATED_REPEAT, \
|
||||
NAMING_LIMITED_EXTEND_E_PREFIXED
|
||||
|
||||
|
||||
episodeCache = {}
|
||||
class TVShow(object):
|
||||
def __init__(self, indexer, indexerid, lang=""):
|
||||
|
||||
|
@ -89,7 +90,7 @@ class TVShow(object):
|
|||
self.lock = threading.Lock()
|
||||
self._isDirGood = False
|
||||
|
||||
self.episodes = {}
|
||||
#self.episodes = {}
|
||||
|
||||
otherShow = helpers.findCertainShow(sickbeard.showList, self.indexerid)
|
||||
if otherShow != None:
|
||||
|
@ -144,11 +145,12 @@ class TVShow(object):
|
|||
|
||||
# delete references to anything that's not in the internal lists
|
||||
def flushEpisodes(self):
|
||||
global episodeCache
|
||||
|
||||
for curSeason in self.episodes:
|
||||
for curEp in self.episodes[curSeason]:
|
||||
myEp = self.episodes[curSeason][curEp]
|
||||
self.episodes[curSeason][curEp] = None
|
||||
for curSeason in episodeCache:
|
||||
for curEp in episodeCache[curSeason]:
|
||||
myEp = episodeCache[curSeason][curEp]
|
||||
episodeCache[curSeason][curEp] = None
|
||||
del myEp
|
||||
|
||||
def getAllEpisodes(self, season=None, has_location=False):
|
||||
|
@ -221,10 +223,10 @@ class TVShow(object):
|
|||
logger.DEBUG)
|
||||
return None
|
||||
|
||||
if not season in self.episodes:
|
||||
self.episodes[season] = {}
|
||||
if not season in episodeCache:
|
||||
episodeCache[season] = {}
|
||||
|
||||
if not episode in self.episodes[season] or self.episodes[season][episode] is None:
|
||||
if not episode in episodeCache[season] or episodeCache[season][episode] is None:
|
||||
if noCreate:
|
||||
return None
|
||||
|
||||
|
@ -247,9 +249,9 @@ class TVShow(object):
|
|||
season, episode)
|
||||
|
||||
if ep != None:
|
||||
self.episodes[season][episode] = ep
|
||||
episodeCache[season][episode] = ep
|
||||
|
||||
epObj = self.episodes[season][episode]
|
||||
epObj = weakref.proxy(episodeCache[season][episode])
|
||||
return epObj
|
||||
|
||||
def should_update(self, update_date=datetime.date.today()):
|
||||
|
@ -1816,6 +1818,7 @@ class TVEpisode(object):
|
|||
return result
|
||||
|
||||
def deleteEpisode(self):
|
||||
global episodeCache
|
||||
|
||||
logger.log(u"Deleting " + self.show.name + " " + str(self.season) + "x" + str(self.episode) + " from the DB",
|
||||
logger.DEBUG)
|
||||
|
@ -1823,7 +1826,7 @@ class TVEpisode(object):
|
|||
# remove myself from the show dictionary
|
||||
if self.show.getEpisode(self.season, self.episode, noCreate=True) == self:
|
||||
logger.log(u"Removing myself from my show's list", logger.DEBUG)
|
||||
del self.show.episodes[self.season][self.episode]
|
||||
del episodeCache[self.season][self.episode]
|
||||
|
||||
# delete myself from the DB
|
||||
logger.log(u"Deleting myself from the database", logger.DEBUG)
|
||||
|
|
|
@ -86,7 +86,6 @@ def _handle_reverse_proxy():
|
|||
|
||||
cherrypy.tools.handle_reverse_proxy = cherrypy.Tool('before_handler', _handle_reverse_proxy)
|
||||
|
||||
|
||||
class PageTemplate(Template):
|
||||
def __init__(self, *args, **KWs):
|
||||
KWs['file'] = os.path.join(sickbeard.PROG_DIR, "gui/" + sickbeard.GUI_NAME + "/interfaces/default/",
|
||||
|
|
Loading…
Reference in a new issue