1
0

More robust when not configured

This commit is contained in:
Jon Michael Aanes 2024-10-23 21:03:20 +02:00
parent bd405b3d5a
commit 0545c9834f
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA

View File

@ -79,8 +79,9 @@ def setup_limiter(
Will always return the given session itself.
"""
if requests_ratelimiter:
if requests_ratelimiter and limiter_args:
session.mount(url_prefix, requests_ratelimiter.LimiterAdapter(**limiter_args))
if requests_cache and expire_after:
session.settings.urls_expire_after[url_prefix] = expire_after
if settings := getattr(session, 'settings', None):
settings.urls_expire_after[url_prefix] = expire_after
return session