Skip to content

Sometimes it broke by concurrent.futures._base.CancelledError  #605

Open
@yanjieee

Description

@yanjieee

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions