Open
Description
When I using Aiomysql in a sanic high concurrency web server:
async with self._pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute(query, param)
if is_all:
res = await cur.fetchall()
else:
res = await cur.fetchone()
Sometimes it broken this error:
Traceback (most recent call last):
File "/usr/local/mycodes/amysql.py", line 249, in query
res = await cur.fetchone()
File "/usr/local/lib/python3.6/site-packages/aiomysql/utils.py", line 103, in __aexit__
await self._pool.release(self._conn)
concurrent.futures._base.CancelledError
or
Traceback (most recent call last):
File "/usr/local/mycodes/amysql.py", line 243, in query
async with self._pool.acquire() as conn:
File "/usr/local/lib/python3.6/site-packages/aiomysql/utils.py", line 98, in __aenter__
self._conn = await self._coro
File "/usr/local/lib/python3.6/site-packages/aiomysql/pool.py", line 133, in _acquire
async with self._cond:
File "/usr/lib64/python3.6/asyncio/locks.py", line 79, in __aenter__
yield from self.acquire()
File "/usr/lib64/python3.6/asyncio/locks.py", line 181, in acquire
yield from fut
concurrent.futures._base.CancelledError
About 1000 request in 10 seconds will cause this error.
What can I do for avoiding this error?
Activity