Aiomysql использую в связке с Aiogram. Эксперементальным путём выяснил, что строка await con.commit() вызывает ошибку приведённую в конце. Но почему?
async def __query(self, *args, **kwargs):
con = await aiomysql.connect(
host=self.__db_host,
user=self.__db_login,
password=self.__db_pass,
db=self.__db_name,
)
cur = await con.cursor()
await cur.execute(*args, **kwargs)
res = await cur.fetchall()
await con.commit()
await cur.close()
Ошибка что возникает:
Traceback (most recent call last):
File "/home/iindin/.local/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
GeneratorExit
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/iindin/.local/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 273, in process_update
return await self.callback_query_handlers.notify(update.callback_query)
File "/home/iindin/.local/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 127, in notify
current_handler.reset(ctx_token)
ValueError: <Token var=<ContextVar name='current_handler' at 0x7f7ab7a7df90> at 0x7f7ab5caa800> was created in a different Context
Exception ignored in: <coroutine object Handler.notify at 0x7f7ab5c42140>
Traceback (most recent call last):
File "/home/iindin/.local/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 127, in notify
current_handler.reset(ctx_token)
ValueError: <Token var=<ContextVar name='current_handler' at 0x7f7ab7a7df90> at 0x7f7ab5c7bc40> was created in a different Context
return res