aiomysql
aiomysql copied to clipboard
coroutine ignored GeneratorExit on sql execute
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?
ä½ å¥½ï¼ææä¸ä¸ªé®é¢ï¼ææ¶æä¼éå°è¿æ ·çé误ï¼å°½ç®¡é常è¿æ®µä»£ç å¯ä»¥æ£å¸¸å·¥ä½ï¼
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
This does not happen if the minimum number of connections is equal to the maximum number of connections