mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
Change add a generic ping function, enabled by update_freq.
This commit is contained in:
parent
9d9dee175f
commit
d3f8be8c3d
4 changed files with 23 additions and 9 deletions
|
@ -1348,9 +1348,10 @@ def start():
|
|||
background_mapping_task.start()
|
||||
|
||||
for p in providers.sortedProviderList():
|
||||
if p.is_active() and hasattr(p, 'ping'):
|
||||
provider_ping_thread_pool[p.get_id()] = threading.Thread(name='PING-PROVIDER %s' % p.get_id(),
|
||||
target=p.ping)
|
||||
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):
|
||||
|
|
|
@ -813,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
|
||||
|
@ -825,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):
|
||||
|
@ -1181,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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -5236,10 +5236,12 @@ class ConfigProviders(Config):
|
|||
|
||||
def checkProvidersPing(self):
|
||||
for p in sickbeard.providers.sortedProviderList():
|
||||
if hasattr(p, 'ping'):
|
||||
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()):
|
||||
sickbeard.provider_ping_thread_pool[p.get_id()] = threading.Thread(name='PING-PROVIDER %s' %
|
||||
p.get_id(), target=p.ping)
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue