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'
|
||||
|
||||
|
||||
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
|
||||
capabilities.
|
||||
"""
|
||||
|
@ -54,12 +54,14 @@ def initialize_session() -> requests.Session:
|
|||
home = pathlib.Path(os.environ['HOME'])
|
||||
cache_path = home / CACHE_PATH_FROM_HOME
|
||||
cache_path.mkdir(parents=True, exist_ok=True)
|
||||
extra_cache_args = extra_cache_args or {}
|
||||
session = requests_cache.CachedSession(
|
||||
cache_path,
|
||||
expire_after=datetime.timedelta(days=1),
|
||||
stale_if_error=True,
|
||||
cache_control=False,
|
||||
urls_expire_after={},
|
||||
**extra_cache_args,
|
||||
)
|
||||
else:
|
||||
session = requests.Session()
|
||||
|
|
Loading…
Reference in New Issue
Block a user