mirror of https://github.com/morpheus65535/bazarr
Merge pull request #585 from ngosang/feature/status
Improve provider throttle / status to handle all exceptions
This commit is contained in:
commit
9ca305740b
|
@ -141,10 +141,11 @@ def provider_throttle(name, exception):
|
||||||
throttle_data = PROVIDER_THROTTLE_MAP.get(name, PROVIDER_THROTTLE_MAP["default"]).get(cls, None) or \
|
throttle_data = PROVIDER_THROTTLE_MAP.get(name, PROVIDER_THROTTLE_MAP["default"]).get(cls, None) or \
|
||||||
PROVIDER_THROTTLE_MAP["default"].get(cls, None)
|
PROVIDER_THROTTLE_MAP["default"].get(cls, None)
|
||||||
|
|
||||||
if not throttle_data:
|
if throttle_data:
|
||||||
return
|
throttle_delta, throttle_description = throttle_data
|
||||||
|
else:
|
||||||
|
throttle_delta, throttle_description = datetime.timedelta(minutes=10), "10 minutes"
|
||||||
|
|
||||||
throttle_delta, throttle_description = throttle_data
|
|
||||||
throttle_until = datetime.datetime.now() + throttle_delta
|
throttle_until = datetime.datetime.now() + throttle_delta
|
||||||
|
|
||||||
if cls_name not in VALID_COUNT_EXCEPTIONS or throttled_count(name):
|
if cls_name not in VALID_COUNT_EXCEPTIONS or throttled_count(name):
|
||||||
|
|
|
@ -186,12 +186,9 @@ class SZProviderPool(ProviderPool):
|
||||||
except (requests.Timeout, socket.timeout):
|
except (requests.Timeout, socket.timeout):
|
||||||
logger.error('Provider %r timed out', provider)
|
logger.error('Provider %r timed out', provider)
|
||||||
|
|
||||||
except (TooManyRequests, DownloadLimitExceeded, ServiceUnavailable, APIThrottled), e:
|
except Exception as e:
|
||||||
self.throttle_callback(provider, e)
|
|
||||||
return
|
|
||||||
|
|
||||||
except:
|
|
||||||
logger.exception('Unexpected error in provider %r: %s', provider, traceback.format_exc())
|
logger.exception('Unexpected error in provider %r: %s', provider, traceback.format_exc())
|
||||||
|
self.throttle_callback(provider, e)
|
||||||
|
|
||||||
def list_subtitles(self, video, languages):
|
def list_subtitles(self, video, languages):
|
||||||
"""List subtitles.
|
"""List subtitles.
|
||||||
|
|
Loading…
Reference in New Issue