fix #951 不缓存网络错误导致的TMDB信息None
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import time
|
||||
from typing import Any
|
||||
from functools import lru_cache
|
||||
|
||||
|
||||
def retry(ExceptionToCheck: Any,
|
||||
@ -32,3 +33,22 @@ def retry(ExceptionToCheck: Any,
|
||||
return f_retry
|
||||
|
||||
return deco_retry
|
||||
|
||||
|
||||
def lru_cache_without_none(maxsize=None, typed=False):
|
||||
"""
|
||||
不缓存None的lru_cache
|
||||
:param maxsize: 缓存大小
|
||||
:param typed: 是否区分参数类型
|
||||
"""
|
||||
def decorator(func):
|
||||
cache = lru_cache(maxsize=maxsize, typed=typed)(func)
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
result = cache(*args, **kwargs)
|
||||
if result is not None:
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
Reference in New Issue
Block a user