mkt.databases.requests_wrapper

Cached HTTP session wrapper (requests-cache) with retry handling.

Provides get_cached_session(), a cached requests_cache.CachedSession with retry logic, used for all HTTP calls across the databases package.

Functions

add_retry_to_session(session[, retries, ...])

Add retry logic to a session.

get_cached_session()

Get a cached session.

mkt.databases.requests_wrapper.add_retry_to_session(session, retries=5, backoff_factor=0.3, status_forcelist=(429, 500, 501, 502, 503, 504))[source]

Add retry logic to a session.

Parameters:
  • session (requests.Session) – Session object

  • retries (int) – Number of retries

  • backoff_factor (float) – Backoff factor

  • status_forcelist (tuple[int]) – Tuple of status codes to force a retry

Returns:

Session object with retry logic

Return type:

requests.Session

mkt.databases.requests_wrapper.get_cached_session()[source]

Get a cached session.

Returns:

Cached session object

Return type:

requests.Session