Extra args
This commit is contained in:
parent
6c983780bc
commit
bfc51fedf0
|
@ -43,7 +43,7 @@ except ImportError:
|
||||||
CACHE_PATH_FROM_HOME = '.local/share/usagi-keiretsu/fin_data/http_cache'
|
CACHE_PATH_FROM_HOME = '.local/share/usagi-keiretsu/fin_data/http_cache'
|
||||||
|
|
||||||
|
|
||||||
def initialize_session() -> requests.Session:
|
def initialize_session(extra_cache_args: dict | None = None) -> requests.Session:
|
||||||
"""Creates Session with or without caching depending upon current
|
"""Creates Session with or without caching depending upon current
|
||||||
capabilities.
|
capabilities.
|
||||||
"""
|
"""
|
||||||
|
@ -54,12 +54,14 @@ def initialize_session() -> requests.Session:
|
||||||
home = pathlib.Path(os.environ['HOME'])
|
home = pathlib.Path(os.environ['HOME'])
|
||||||
cache_path = home / CACHE_PATH_FROM_HOME
|
cache_path = home / CACHE_PATH_FROM_HOME
|
||||||
cache_path.mkdir(parents=True, exist_ok=True)
|
cache_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
extra_cache_args = extra_cache_args or {}
|
||||||
session = requests_cache.CachedSession(
|
session = requests_cache.CachedSession(
|
||||||
cache_path,
|
cache_path,
|
||||||
expire_after=datetime.timedelta(days=1),
|
expire_after=datetime.timedelta(days=1),
|
||||||
stale_if_error=True,
|
stale_if_error=True,
|
||||||
cache_control=False,
|
cache_control=False,
|
||||||
urls_expire_after={},
|
urls_expire_after={},
|
||||||
|
**extra_cache_args,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user