gchar.utils.session¶
get_requests_session¶
-
gchar.utils.session.
get_requests_session
(max_retries: int = 5, timeout: int = 10, headers: Optional[Dict[str, str]] = None, session: Optional[requests.Session] = None) → requests.Session[source]¶ Returns a requests Session object configured with retry and timeout settings.
- Parameters:
max_retries (int) – The maximum number of retries. (default: 5)
timeout (int) – The default timeout value in seconds. (default: 10)
headers (Optional[Dict[str, str]]) – Additional headers to be added to the session. (default: None)
session (Optional[requests.Session]) – An existing requests Session object to use. If not provided, a new Session object is created. (default: None)
- Returns:
The requests Session object.
- Return type:
requests.Session
srequest¶
-
gchar.utils.session.
srequest
(session: requests.Session, method, url, *, max_retries: int = 5, sleep_time: float = 5.0, raise_for_status: bool = True, **kwargs) → requests.Response[source]¶ Send a request using the provided session object with retry and timeout settings.
- Parameters:
session (requests.Session) – The requests Session object to use for the request.
method (str) – The HTTP method for the request.
url (str) – The URL for the request.
max_retries (int) – The maximum number of retries. (default: 5)
sleep_time (float) – The sleep time between retries in seconds. (default: 5.0)
raise_for_status (bool) – Whether to raise an exception for non-successful response status codes. (default: True)
kwargs (dict) – Additional keyword arguments for the request.
- Returns:
The response from the request.
- Return type:
requests.Response
sget¶
-
gchar.utils.session.
sget
(session: requests.Session, url, *, max_retries: int = 5, sleep_time: float = 5.0, raise_for_status: bool = True, **kwargs) → requests.Response[source]¶ Send a GET request using the provided session object with retry and timeout settings.
- Parameters:
session (requests.Session) – The requests Session object to use for the request.
url (str) – The URL for the request.
max_retries (int) – The maximum number of retries. (default: 5)
sleep_time (float) – The sleep time between retries in seconds. (default: 5.0)
raise_for_status (bool) – Whether to raise an exception for non-successful response status codes. (default: True)
kwargs (dict) – Additional keyword arguments for the request.
- Returns:
The response from the request.
- Return type:
requests.Response