aiomysql icon indicating copy to clipboard operation
aiomysql copied to clipboard

coroutine ignored GeneratorExit on sql execute

Open suregoodru opened this issue 3 years ago • 2 comments

Hi! I have a problem, Sometimes I get errors like this, although usually this code works without problems:

await db.execute("UPDATE inventory SET a = a - 1 WHERE id = %s AND peerid = %s", (id, peerid))
RuntimeError: coroutine ignored GeneratorExit

in db.execute I have this code:

    async with self.connection.acquire() as con:
          con: aiomysql.Connection
          async with con.cursor(aiomysql.cursors.DictCursor) as cursor:
              cursor: aiomysql.Cursor
              result = await cursor.execute(query, args)
              result = await con.commit()
      return result

for self.connection I use pool with this code:

self.connection = await aiomysql.create_pool(host=host,
                                                     user=base_user,
                                                     password=base_pass,
                                                     db=base,
                                                     charset=base_charset,
                                                     autocommit=True,
                                                     pool_recycle=31536000,
                                                     )

Can you help me find mistake?

suregoodru avatar Dec 16 '21 12:12 suregoodru

你好!我有一个问题,有时我会遇到这样的错误,尽管通常这段代码可以正常工作:

await db.execute("UPDATE inventory SET a = a - 1 WHERE id = %s AND peerid = %s", (id, peerid))
RuntimeError: coroutine ignored GeneratorExit

在 db.execute 我有这个代码:

    async with self.connection.acquire() as con:
          con: aiomysql.Connection
          async with con.cursor(aiomysql.cursors.DictCursor) as cursor:
              cursor: aiomysql.Cursor
              result = await cursor.execute(query, args)
              result = await con.commit()
      return result

对于 self.connection,我使用带有以下代码的池:

self.connection = await aiomysql.create_pool(host=host,
                                                     user=base_user,
                                                     password=base_pass,
                                                     db=base,
                                                     charset=base_charset,
                                                     autocommit=True,
                                                     pool_recycle=31536000,
                                                     )

你能帮我找出错误吗?

Hi! I have a problem, Sometimes I get errors like this, although usually this code works without problems:

await db.execute("UPDATE inventory SET a = a - 1 WHERE id = %s AND peerid = %s", (id, peerid))
RuntimeError: coroutine ignored GeneratorExit

in db.execute I have this code:

    async with self.connection.acquire() as con:
          con: aiomysql.Connection
          async with con.cursor(aiomysql.cursors.DictCursor) as cursor:
              cursor: aiomysql.Cursor
              result = await cursor.execute(query, args)
              result = await con.commit()
      return result

for self.connection I use pool with this code:

self.connection = await aiomysql.create_pool(host=host,
                                                     user=base_user,
                                                     password=base_pass,
                                                     db=base,
                                                     charset=base_charset,
                                                     autocommit=True,
                                                     pool_recycle=31536000,
                                                     )

Can you help me find mistake?

I have the same problem with high concurrency

flask-rabmq avatar Aug 19 '22 14:08 flask-rabmq

This does not happen if the minimum number of connections is equal to the maximum number of connections

flask-rabmq avatar Aug 19 '22 14:08 flask-rabmq