graviti.utility.requests
#
The implementation of request related tools.
Module Contents#
Classes#
This is a base class defining the concept of Request Config. |
|
This class defines the http adapter for setting the timeout value. |
|
This class defines UserSession. |
|
This class used to read data from Response with stream method. |
Functions#
Create and return a session per PID so each sub-processes will use their own session. |
|
|
Multi-thread framework. |
Attributes#
- class graviti.utility.requests.Config[source]#
This is a base class defining the concept of Request Config.
- max_retries#
Maximum retry times of the request.
- allowed_retry_methods#
The allowed methods for retrying request.
- allowed_retry_status#
The allowed status for retrying request. If both methods and status are fitted, the retrying strategy will work.
- timeout#
Timeout value of the request in seconds.
- is_internal#
Whether the request is from internal.
- class graviti.utility.requests.TimeoutHTTPAdapter(*args, timeout=None, **kwargs)[source]#
Bases:
requests.adapters.HTTPAdapter
This class defines the http adapter for setting the timeout value.
- Parameters
- send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None)[source]#
Send the request.
- Parameters
request (requests.models.PreparedRequest) – The PreparedRequest being sent.
stream (Any) – Whether to stream the request content.
timeout (Any) – Timeout value of the post request in seconds.
verify (Any) – A path string to a CA bundle to use or a boolean which controls whether to verify the server’s TLS certificate.
cert (Any) – User-provided SSL certificate.
proxies (Any) – Proxies dict applying to the request.
- Returns
Response object.
- Return type
- class graviti.utility.requests.UserSession[source]#
Bases:
requests.Session
This class defines UserSession.
- request(self, method, url, *args, **kwargs)[source]#
Make the request.
- Parameters
- Returns
Response of the request.
- Raises
ResponseError – If post response error.
- Return type
requests.models.Response
- graviti.utility.requests.get_session()[source]#
Create and return a session per PID so each sub-processes will use their own session.
- Returns
The session corresponding to the process.
- Return type
- class graviti.utility.requests.UserResponse(response)[source]#
This class used to read data from Response with stream method.
- Parameters
response (requests.models.Response) – Response of the Session.request().
- graviti.utility.requests.submit_multithread_tasks(function, arguments, *, jobs)[source]#
Multi-thread framework.
- Parameters
function (Callable[[_T], Any]) – The function to call.
arguments (Iterable[_T]) – The arguments of the function.
jobs (int) – The number of the max workers in multi-thread call procession.
- Return type
None