I would like to make a custom retry behaviour for different error types. For example if I receive a 401 Error I would like to call a token refresh before retring a request. If I receive a 500 I would like to retry the error after some time. etc.
Is this achievable with the tenacity library? https://tenacity.readthedocs.io/en/latest/