Трассировка python Tenacity вместо кода состояния
Я хотел бы посмотреть, как я могу захватить код состояния для каждого запроса с помощью Tenacity, вот текущий env блока кода:python 3.6.8aiohttpTenacity
async with aiohttp.ClientSession(raise_for_status=True,timeout=self.api_request_timeout,headers=headers) as client:
async for attempt in AsyncRetrying(stop=stop_after_attempt(self.api_retry_max_attempts), reraise=True, wait=wait_fixed(self.api_retry_wait_secs), before_sleep=before_sleep_log(self.logger, logging.ERROR, exc_info=True)):
with attempt:
async with (client.get(api_endpoint_url) if method == 'get' else client.post(api_endpoint_url, json=req_data)) as resp:
resp_data = await resp.json()
здесь я ожидал увидеть
{
"error": "invalid_grant",
"error_description": "Invalid or expired device code."
}
вместо этого я вижу трассировку
ERROR:app:Retrying None in 5.0 seconds as it raised ClientResponseError: 403, message='Forbidden', url=URL('https://website/oauth/token').
Traceback (most recent call last):
File "project/profile/repos.py", line 75, in _invoke_uma_api
client.post(api_endpoint_url, json=req_data)) as resp:
File "project/venv/lib/python3.6/site-packages/aiohttp-3.6.2-py3.6.egg/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "project/venv/lib/python3.6/site-packages/aiohttp-3.6.2-py3.6.egg/aiohttp/client.py", line 588, in _request
resp.raise_for_status()
File "project/venv/lib/python3.6/site-packages/aiohttp-3.6.2-py3.6.egg/aiohttp/client_reqrep.py", line 946, in raise_for_status
headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url=URL('https://website/oauth/token')