Status
Implementations which handle various status codes.
- Some operations include:
Re-authorising when a ‘Not Authorised’ status is returned.
Waiting until rate limit time has expired when a ‘Too Many Requests’ status is returned.
Classes:
Handles a response that matches the status conditions of this handler according to its status, payload, headers, etc. |
|
Handles status codes which cannot be handled, raising an error. |
|
Handles unauthorised response status codes by re-authorising credentials through an |
|
Handles rate limits by increasing a timer value for every response that returns a rate limit status. |
- class aiorequestful.response.status.StatusHandler
Bases:
ABC
Handles a response that matches the status conditions of this handler according to its status, payload, headers, etc.
Attributes:
The response status codes this handler can handle.
The
logging.Logger
for this objectMethods:
match
(response[, fail_on_error])Check if this handler settings match the given response.
handle
(response, *_, **__)Handle the response based on its status, payload response etc.
- abstract property status_codes: list[int]
The response status codes this handler can handle.
-
logger:
Logger
The
logging.Logger
for this object
- match(response, fail_on_error=False)
Check if this handler settings match the given response.
- Parameters:
response (
ClientResponse
) – The response to match.fail_on_error (
bool
(default:False
)) – Raise an exception if the response does not match this handler.
- Raises:
StatusHandlerError – If match fails and fail_on_error is True.
- Return type:
bool
- abstractmethod async handle(response, *_, **__)
Handle the response based on its status, payload response etc.
- Parameters:
response (
ClientResponse
) – The response to handle.- Returns:
bool
– True if the response was handled, False if it was not.
- class aiorequestful.response.status.ClientErrorStatusHandler
Bases:
StatusHandler
Handles status codes which cannot be handled, raising an error.
Attributes:
The response status codes this handler can handle.
Methods:
handle
(response, *_, **__)Handle the response based on its status, payload response etc.
- property status_codes: list[int]
The response status codes this handler can handle.
- async handle(response, *_, **__)
Handle the response based on its status, payload response etc.
- Parameters:
response (
ClientResponse
) – The response to handle.- Returns:
NoReturn
– True if the response was handled, False if it was not.
- class aiorequestful.response.status.UnauthorisedStatusHandler
Bases:
StatusHandler
Handles unauthorised response status codes by re-authorising credentials through an
Authoriser
.Attributes:
The response status codes this handler can handle.
Methods:
handle
(response[, authoriser, session])Handle the response based on its status, payload response etc.
- property status_codes: list[int]
The response status codes this handler can handle.
- async handle(response, authoriser=None, session=None, *_, **__)
Handle the response based on its status, payload response etc.
- Parameters:
response (
ClientResponse
) – The response to handle.- Returns:
bool
– True if the response was handled, False if it was not.
- class aiorequestful.response.status.RateLimitStatusHandler
Bases:
StatusHandler
Handles rate limits by increasing a timer value for every response that returns a rate limit status.
Attributes:
The response status codes this handler can handle.
Methods:
handle
(response[, wait_timer, retry_timer])Handle the response based on its status, payload response etc.
- property status_codes: list[int]
The response status codes this handler can handle.
- async handle(response, wait_timer=None, retry_timer=None, *_, **__)
Handle the response based on its status, payload response etc.
- Parameters:
response (
ClientResponse
) – The response to handle.- Returns:
bool
– True if the response was handled, False if it was not.