Merge branch 'hotfix/0.12.27'

This commit is contained in:
JackDandy 2017-08-22 19:01:28 +01:00
commit 8166cd9686
6 changed files with 85 additions and 4 deletions

View file

@ -1,4 +1,9 @@
### 0.12.26 (2017-08-20 13:05:00 UTC)
### 0.12.27 (2017-08-22 19:00:00 UTC)
* Update to UnRar 5.50 release
### 0.12.26 (2017-08-20 13:05:00 UTC)
* Fix infinite loop loading network_timezones
* Change add optional "stack_size" setting as integer to config.ini under "General" stanza

Binary file not shown.

View file

@ -86,6 +86,8 @@ subtitlesFinderScheduler = None
# traktCheckerScheduler = None
background_mapping_task = None
provider_ping_thread_pool = {}
showList = None
UPDATE_SHOWS_ON_START = False
SHOW_UPDATE_HOUR = 3
@ -523,7 +525,8 @@ def initialize(console_logging=True):
# global traktCheckerScheduler
global recentSearchScheduler, backlogSearchScheduler, showUpdateScheduler, \
versionCheckScheduler, showQueueScheduler, searchQueueScheduler, \
properFinderScheduler, autoPostProcesserScheduler, subtitlesFinderScheduler, background_mapping_task
properFinderScheduler, autoPostProcesserScheduler, subtitlesFinderScheduler, background_mapping_task, \
provider_ping_thread_pool
# Add Show Defaults
global STATUS_DEFAULT, QUALITY_DEFAULT, SHOW_TAG_DEFAULT, FLATTEN_FOLDERS_DEFAULT, SUBTITLES_DEFAULT, \
WANTED_BEGIN_DEFAULT, WANTED_LATEST_DEFAULT, SCENE_DEFAULT, ANIME_DEFAULT
@ -1344,6 +1347,13 @@ def start():
indexermapper.indexer_list = [i for i in indexerApi().all_indexers]
background_mapping_task.start()
for p in providers.sortedProviderList():
if p.is_active() and getattr(p, 'ping_freq', None):
# noinspection PyProtectedMember
provider_ping_thread_pool[p.get_id()] = threading.Thread(
name='PING-PROVIDER %s' % p.name, target=p._ping)
provider_ping_thread_pool[p.get_id()].start()
for thread in enabled_schedulers(is_init=True):
thread.start()
@ -1390,6 +1400,15 @@ def halt():
except RuntimeError:
pass
for p in provider_ping_thread_pool:
provider_ping_thread_pool[p].stop = True
for p in provider_ping_thread_pool:
try:
provider_ping_thread_pool[p].join(10)
except RuntimeError:
pass
if ADBA_CONNECTION:
try:
ADBA_CONNECTION.logout()

View file

@ -26,6 +26,7 @@ import os
import re
import time
import urlparse
import threading
from urllib import quote_plus
import zlib
from base64 import b16encode, b32decode
@ -702,6 +703,19 @@ class GenericProvider:
pass
return long(math.ceil(value))
def _should_stop(self):
if getattr(threading.currentThread(), 'stop', False):
return True
return False
def _sleep_with_stop(self, t):
t_l = t
while t_l > 0:
time.sleep(3)
t_l -= 3
if self._should_stop():
return
class NZBProvider(object, GenericProvider):
@ -799,7 +813,7 @@ class NZBProvider(object, GenericProvider):
class TorrentProvider(object, GenericProvider):
def __init__(self, name, supports_backlog=True, anime_only=False, cache_update_freq=None):
def __init__(self, name, supports_backlog=True, anime_only=False, cache_update_freq=None, update_freq=None):
GenericProvider.__init__(self, name, supports_backlog, anime_only)
self.providerType = GenericProvider.TORRENT
@ -811,6 +825,8 @@ class TorrentProvider(object, GenericProvider):
self.cache._cache_data = self._cache_data
if cache_update_freq:
self.cache.update_freq = cache_update_freq
self.ping_freq = update_freq
self.ping_skip = None
@property
def url(self):
@ -1167,3 +1183,12 @@ class TorrentProvider(object, GenericProvider):
def _cache_data(self):
return self._search_provider({'Cache': ['']})
def _ping(self):
while not self._should_stop():
if self.ping_skip:
self.ping_skip -= 1
else:
self.ping_skip = ((60*60)/self.ping_freq, None)[self._authorised()]
self._sleep_with_stop(self.ping_freq)

View file

@ -26,7 +26,7 @@ from sickbeard.helpers import tryInt
class SpeedCDProvider(generic.TorrentProvider):
def __init__(self):
generic.TorrentProvider.__init__(self, 'SpeedCD', cache_update_freq=20)
generic.TorrentProvider.__init__(self, 'SpeedCD', cache_update_freq=20, update_freq=4*60)
self.url_base = 'https://speed.cd/'
self.urls = {'config_provider_home_uri': self.url_base,

View file

@ -5234,6 +5234,35 @@ class ConfigProviders(Config):
return '1'
def checkProvidersPing(self):
for p in sickbeard.providers.sortedProviderList():
if getattr(p, 'ping_freq', None):
if p.is_active() and (p.get_id() not in sickbeard.provider_ping_thread_pool
or not sickbeard.provider_ping_thread_pool[p.get_id()].is_alive()):
# noinspection PyProtectedMember
sickbeard.provider_ping_thread_pool[p.get_id()] = threading.Thread(
name='PING-PROVIDER %s' % p.name, target=p._ping)
sickbeard.provider_ping_thread_pool[p.get_id()].start()
elif not p.is_active() and p.get_id() in sickbeard.provider_ping_thread_pool:
sickbeard.provider_ping_thread_pool[p.get_id()].stop = True
try:
sickbeard.provider_ping_thread_pool[p.get_id()].join(120)
if not sickbeard.provider_ping_thread_pool[p.get_id()].is_alive():
sickbeard.provider_ping_thread_pool.pop(p.get_id())
except RuntimeError:
pass
# stop removed providers
prov = [n.get_id() for n in sickbeard.providers.sortedProviderList()]
for p in [x for x in sickbeard.provider_ping_thread_pool if x not in prov]:
sickbeard.provider_ping_thread_pool[p].stop = True
try:
sickbeard.provider_ping_thread_pool[p].join(120)
if not sickbeard.provider_ping_thread_pool[p].is_alive():
sickbeard.provider_ping_thread_pool.pop(p)
except RuntimeError:
pass
def saveProviders(self, newznab_string='', torrentrss_string='', provider_order=None, **kwargs):
results = []
@ -5426,6 +5455,9 @@ class ConfigProviders(Config):
sickbeard.save_config()
cp = threading.Thread(name='Check-Ping-Providers', target=self.checkProvidersPing)
cp.start()
if 0 < len(results):
for x in results:
logger.log(x, logger.ERROR)