Error handled cursors closing
This commit is contained in:
13
dbs/mysql.py
13
dbs/mysql.py
@@ -24,8 +24,8 @@ async def close_old_cached_cursors():
|
||||
continue
|
||||
|
||||
try:
|
||||
await cursor.close()
|
||||
cached_cursors.pop(cursor_id, None)
|
||||
await cursor.close()
|
||||
closed_cached_cursors[cursor_id] = cursor
|
||||
print(f"Closed cursor {cursor_id}")
|
||||
except Exception as e:
|
||||
@@ -51,13 +51,18 @@ async def remove_old_closed_cached_cursors():
|
||||
async def cached_cursors_cleaner():
|
||||
global cached_cursors, closed_cached_cursors
|
||||
while True:
|
||||
await close_old_cached_cursors()
|
||||
await remove_old_closed_cached_cursors()
|
||||
try:
|
||||
await close_old_cached_cursors()
|
||||
except Exception as e:
|
||||
print(f"Error closing some cached cursors, {e=}")
|
||||
try:
|
||||
await remove_old_closed_cached_cursors()
|
||||
except Exception as e:
|
||||
print(f"Error removing closed cursors, {e=}")
|
||||
await asyncio.sleep(10)
|
||||
|
||||
|
||||
async def pool_creator(connection: Connection, minsize=5, maxsize=10):
|
||||
|
||||
return await aiomysql.create_pool(
|
||||
host=connection.host,
|
||||
user=connection.username,
|
||||
|
||||
Reference in New Issue
Block a user