我遇到了 aiohttp 的问题,出现以下错误,但不确定修复它的最佳方法:
Traceback (most recent call last):
File "/app/app/services/file_ingestion_utils.py", line 110, in send_api_request
async with session.post(url, headers=self.headers, data=payload) as response:
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 544, in _request
await resp.start(conn)
File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 905, in start
self._continue = None
File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 656, in __exit__
raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
Run Code Online (Sandbox Code Playgroud)
我从这里看到这些错误可能有点模糊,但我至少想了解至少在我的情况下导致这些错误的原因。我的实现如下所示。
async def async_request(self, df, entity):
api_request_records = []
...some logic to prepare records...
@backoff.on_exception(backoff.expo, aiohttp.ClientError, max_tries=2)
async def …Run Code Online (Sandbox Code Playgroud)