Private GIT

Skip to content
Snippets Groups Projects
Commit bcf32f60 authored by miigotu's avatar miigotu
Browse files

Dont update cache for all providers at the same time, causes huge cpu/memory...

Dont update cache for all providers at the same time, causes huge cpu/memory spike on low resource devices
Also it mixes logs up and thrashes a bit
Lint sickbeard.providers.__init__ and remove filter calls, and redefinition of newznab
parent 95c505af
Branches
Tags
No related merge requests found
......@@ -23,7 +23,7 @@ from random import shuffle
import sickbeard
from sickbeard import logger
from sickbeard.providers import btn, newznab, womble, thepiratebay, torrentleech, kat, iptorrents, torrentz, \
from sickbeard.providers import btn, newznab, rsstorrent, womble, thepiratebay, torrentleech, kat, iptorrents, torrentz, \
omgwtfnzbs, scc, hdtorrents, torrentday, hdbits, hounddawgs, speedcd, nyaatorrents, animenzb, bluetigers, cpasbien, fnt, xthor, torrentbytes, \
freshontv, titansoftv, morethantv, bitsoup, t411, tokyotoshokan, shazbat, rarbg, alpharatio, tntvillage, binsearch, torrentproject, extratorrent, \
scenetime, btdigg, strike, transmitthenet, tvchaosuk, bitcannon, pretome, gftracker, hdspace, newpct, elitetorrent, bitsnoop, danishbits
......@@ -73,7 +73,7 @@ def makeProviderList():
def getNewznabProviderList(data):
defaultList = [makeNewznabProvider(x) for x in getDefaultNewznabProviders().split('!!!')]
providerList = filter(lambda x: x, [makeNewznabProvider(x) for x in data.split('!!!')])
providerList = [x for x in [makeNewznabProvider(x) for x in data.split('!!!')] if x]
seen_values = set()
providerListDeduped = []
......@@ -103,7 +103,7 @@ def getNewznabProviderList(data):
providerDict[curDefault.name].enable_daily = curDefault.enable_daily
providerDict[curDefault.name].enable_backlog = curDefault.enable_backlog
return filter(lambda x: x, providerList)
return [x for x in providerList if x]
def makeNewznabProvider(configString):
......@@ -129,7 +129,7 @@ def makeNewznabProvider(configString):
logger.log(u"Skipping Newznab provider string: '" + configString + "', incorrect format", logger.ERROR)
return None
newznab = sys.modules['sickbeard.providers.newznab']
# newznab = sys.modules['sickbeard.providers.newznab']
newProvider = newznab.NewznabProvider(name, url, key=key, catIDs=catIDs, search_mode=search_mode,
search_fallback=search_fallback, enable_daily=enable_daily,
......@@ -140,7 +140,7 @@ def makeNewznabProvider(configString):
def getTorrentRssProviderList(data):
providerList = filter(lambda x: x, [makeTorrentRssProvider(x) for x in data.split('!!!')])
providerList = [x for x in [makeTorrentRssProvider(x) for x in data.split('!!!')] if x]
seen_values = set()
providerListDeduped = []
......@@ -150,7 +150,7 @@ def getTorrentRssProviderList(data):
providerListDeduped.append(d)
seen_values.add(value)
return filter(lambda x: x, providerList)
return [x for x in providerList if x]
def makeTorrentRssProvider(configString):
......@@ -179,12 +179,12 @@ def makeTorrentRssProvider(configString):
logger.ERROR)
return None
try:
torrentRss = sys.modules['sickbeard.providers.rsstorrent']
except Exception:
return
# try:
# torrentRss = sys.modules['sickbeard.providers.rsstorrent']
# except Exception:
# return
newProvider = torrentRss.TorrentRssProvider(name, url, cookies, titleTAG, search_mode, search_fallback, enable_daily,
newProvider = rsstorrent.TorrentRssProvider(name, url, cookies, titleTAG, search_mode, search_fallback, enable_daily,
enable_backlog)
newProvider.enabled = enabled == '1'
......
......@@ -367,7 +367,6 @@ def searchForNeededEpisodes():
didSearch = False
origThreadName = threading.currentThread().name
threads = []
show_list = sickbeard.showList
fromDate = datetime.date.fromordinal(1)
......@@ -375,19 +374,15 @@ def searchForNeededEpisodes():
for curShow in show_list:
if not curShow.paused:
sickbeard.name_cache.buildNameCache(curShow)
episodes.extend(wantedEpisodes(curShow, fromDate))
providers = [x for x in sickbeard.providers.sortedProviderList(sickbeard.RANDOMIZE_PROVIDERS) if x.is_active() and x.enable_daily]
for curProvider in providers:
threads += [threading.Thread(target=curProvider.cache.updateCache, name=origThreadName + " :: [" + curProvider.name + "]")]
# start the thread we just created
for t in threads:
t.start()
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
curProvider.cache.updateCache()
# wait for all threads to finish
for t in threads:
t.join()
threading.currentThread().name = origThreadName
for curProvider in providers:
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
......@@ -447,7 +442,6 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False):
finalResults = []
didSearch = False
threads = []
# build name cache for show
sickbeard.name_cache.buildNameCache(show)
......@@ -456,18 +450,12 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False):
providers = [x for x in sickbeard.providers.sortedProviderList(sickbeard.RANDOMIZE_PROVIDERS) if x.is_active() and x.enable_backlog]
for curProvider in providers:
threads += [threading.Thread(target=curProvider.cache.updateCache,
name=origThreadName + " :: [" + curProvider.name + "]")]
# start the thread we just created
for t in threads:
t.start()
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
curProvider.cache.updateCache()
# wait for all threads to finish
for t in threads:
t.join()
threading.currentThread().name = origThreadName
for providerNum, curProvider in enumerate(providers):
for curProvider in providers:
if curProvider.anime_only and not show.is_anime:
logger.log(u"" + str(show.name) + " is not an anime, skiping", logger.DEBUG)
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment