From 0a80d0c3dd9194a5a98ab44256f861eb2c4c1e42 Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 30 Jun 2014 03:20:49 -0700 Subject: [PATCH] Fixed memory leak in scene exceptions. --- sickbeard/__init__.py | 2 +- sickbeard/scene_exceptions.py | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index ae55f657..38be5e02 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -1303,7 +1303,7 @@ def saveAll(): def saveAndShutdown(): halt() saveAll() - + def invoke_command(to_call, *args, **kwargs): def delegate(): diff --git a/sickbeard/scene_exceptions.py b/sickbeard/scene_exceptions.py index 277d076c..e6fdaeb9 100644 --- a/sickbeard/scene_exceptions.py +++ b/sickbeard/scene_exceptions.py @@ -26,20 +26,19 @@ from sickbeard import name_cache from sickbeard import logger from sickbeard import db -MAX_XEM_AGE_SECS = 86400 # 1 day -MAX_ANIDB_AGE_SECS = 86400 # 1 day - -exceptionCache = {} -exceptionSeasonCache = {} -exceptionIndexerCache = {} - +exception_dict = None +exceptionCache = None +exceptionSeasonCache = None +exceptionIndexerCache = None def shouldRefresh(list): + MAX_REFRESH_AGE_SECS = 86400 # 1 day + myDB = db.DBConnection('cache.db') rows = myDB.select("SELECT last_refreshed FROM scene_exceptions_refresh WHERE list = ?", [list]) if rows: - return time.time() > (int(rows[0]['last_refreshed']) + MAX_XEM_AGE_SECS) + return time.time() > (int(rows[0]['last_refreshed']) + MAX_REFRESH_AGE_SECS) else: return True @@ -95,6 +94,7 @@ def get_scene_seasons(indexer_id): return a list of season numbers that have scene exceptions """ global exceptionSeasonCache + if indexer_id not in exceptionSeasonCache: myDB = db.DBConnection('cache.db') sqlResults = myDB.select("SELECT DISTINCT(season) as season FROM scene_exceptions WHERE indexer_id = ?", @@ -148,11 +148,12 @@ def retrieve_exceptions(): scene_exceptions table in cache.db. Also clears the scene name cache. """ - global exceptionCache, exceptionSeasonCache + global exception_dict, exceptionCache, exceptionSeasonCache, exceptionIndexerCache exception_dict = {} exceptionCache = {} exceptionSeasonCache = {} + exceptionIndexerCache = {} # exceptions are stored on github pages if setLastRefresh('normal'): @@ -253,7 +254,6 @@ def update_scene_exceptions(indexer_id, scene_exceptions): name_cache.clearCache() def _retrieve_anidb_mainnames(): - global MAX_ANIDB_AGE_SECS success = False @@ -281,7 +281,6 @@ def _retrieve_anidb_mainnames(): def _xem_excpetions_fetcher(): - global MAX_XEM_AGE_SECS exception_dict = {} @@ -322,9 +321,9 @@ def getSceneSeasons(indexer_id): def buildIndexerCache(): - logger.log(u"Updating internal scene name cache", logger.MESSAGE) global exceptionIndexerCache - exceptionIndexerCache = {} + + logger.log(u"Updating internal scene name cache", logger.MESSAGE) for show in sickbeard.showList: for curSeason in [-1] + sickbeard.scene_exceptions.get_scene_seasons(show.indexerid): @@ -334,4 +333,5 @@ def buildIndexerCache(): exceptionIndexerCache[helpers.full_sanitizeSceneName(name)] = show.indexerid logger.log(u"Updated internal scene name cache", logger.MESSAGE) - logger.log(u"Internal scene name cache set to: " + str(exceptionIndexerCache), logger.DEBUG) \ No newline at end of file + logger.log(u"Internal scene name cache set to: " + str(exceptionIndexerCache), logger.DEBUG) +