Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coroutine ignored GeneratorExit on sql execute #637

Open
suregoodru opened this issue Dec 16, 2021 · 2 comments
Open

coroutine ignored GeneratorExit on sql execute #637

suregoodru opened this issue Dec 16, 2021 · 2 comments
Labels

Comments

@suregoodru
Copy link

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?

@flask-rabmq
Copy link

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

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants