diff --git a/requests_util/__init__.py b/requests_util/__init__.py index 8dafd8d..ccefc71 100644 --- a/requests_util/__init__.py +++ b/requests_util/__init__.py @@ -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