mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-11 09:17:47 +08:00
Empty cache when ValueError is raised with 'unsupported pickle protocol: 3'. This happen when cache have been pickled with Python3 but is read by Python2.
This commit is contained in:
parent
d92e7755d3
commit
6a2e2e0f5a
1 changed files with 15 additions and 7 deletions
|
@ -10,6 +10,7 @@ from get_args import args
|
||||||
from config import settings
|
from config import settings
|
||||||
from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError
|
from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError
|
||||||
from subliminal.exceptions import DownloadLimitExceeded, ServiceUnavailable
|
from subliminal.exceptions import DownloadLimitExceeded, ServiceUnavailable
|
||||||
|
from subliminal import region as subliminal_cache_region
|
||||||
|
|
||||||
VALID_THROTTLE_EXCEPTIONS = (TooManyRequests, DownloadLimitExceeded, ServiceUnavailable, APIThrottled,
|
VALID_THROTTLE_EXCEPTIONS = (TooManyRequests, DownloadLimitExceeded, ServiceUnavailable, APIThrottled,
|
||||||
ParseResponseError)
|
ParseResponseError)
|
||||||
|
@ -154,6 +155,13 @@ def provider_throttle(name, exception):
|
||||||
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):
|
||||||
|
if cls_name == 'ValueError' and exception.message.startswith('unsupported pickle protocol'):
|
||||||
|
for fn in subliminal_cache_region.backend.all_filenames:
|
||||||
|
try:
|
||||||
|
os.remove(fn)
|
||||||
|
except (IOError, OSError):
|
||||||
|
logging.debug("Couldn't remove cache file: %s", os.path.basename(fn))
|
||||||
|
else:
|
||||||
tp[name] = (cls_name, throttle_until, throttle_description)
|
tp[name] = (cls_name, throttle_until, throttle_description)
|
||||||
settings.general.throtteled_providers = str(tp)
|
settings.general.throtteled_providers = str(tp)
|
||||||
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
|
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
|
||||||
|
|
Loading…
Reference in a new issue