From c96fb2066306ce9e18fed4d4f47ca5178d11f668 Mon Sep 17 00:00:00 2001 From: ngosang Date: Sun, 22 Sep 2019 17:33:04 +0200 Subject: [PATCH] Improve provider throttle / status to handle all exceptions --- bazarr/get_providers.py | 7 ++++--- libs/subliminal_patch/core.py | 7 ++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/bazarr/get_providers.py b/bazarr/get_providers.py index 461a21615..a2f12559f 100644 --- a/bazarr/get_providers.py +++ b/bazarr/get_providers.py @@ -141,10 +141,11 @@ def provider_throttle(name, exception): throttle_data = PROVIDER_THROTTLE_MAP.get(name, PROVIDER_THROTTLE_MAP["default"]).get(cls, None) or \ PROVIDER_THROTTLE_MAP["default"].get(cls, None) - if not throttle_data: - return + if throttle_data: + 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 if cls_name not in VALID_COUNT_EXCEPTIONS or throttled_count(name): diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index 363477e1f..171d85528 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -186,12 +186,9 @@ class SZProviderPool(ProviderPool): except (requests.Timeout, socket.timeout): logger.error('Provider %r timed out', provider) - except (TooManyRequests, DownloadLimitExceeded, ServiceUnavailable, APIThrottled), e: - self.throttle_callback(provider, e) - return - - except: + except Exception as e: logger.exception('Unexpected error in provider %r: %s', provider, traceback.format_exc()) + self.throttle_callback(provider, e) def list_subtitles(self, video, languages): """List subtitles.