Использую библиотеку aiogram и aiomysql. Когда нажимаю на кнопку в боте несколько раз подряд или одновременно на двух аккаунтах - выдает ошибку:
spoilerTask was destroyed but it is pending!
task: wait_for=<_GatheringFuture pending cb=[Task.task_wakeup()]>>
Exception ignored in:
Traceback (most recent call last):
File "C:\Users\Kondor_PC\Desktop\bots\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 126, in notify
current_handler.reset(ctx_token)
ValueError: at 0x00000223B9D95500> was created in a different Context
Код:
from data_base import mysql_db
async def command_info(message: types.Message):
user = await mysql_db.sql_query(str(message.from_user.id))
await bot.send_message(message.from_user.id, "Мой ID:" + str(user[0][2]) + "\n\nМонеты: " + str(user[0][4]),
parse_mode="Markdown")
Модуль mysql_db:
loop = asyncio.get_event_loop()
async def sql_query(users):
try:
conn = await aiomysql.connect(host='None', user='None',
password='None', db='None',
loop=loop)
cur = await conn.cursor()
await cur.execute("SELECT * FROM users WHERE username='" + str(users) + "'")
print("You have successfully query")
r = await cur.fetchall()
print(r)
await cur.close()
conn.close()
except Error:
print("Wrong HOST or LOGIN or PASSWORD.")
raise (SystemExit)
if __name__ == '__main__':
loop.run_until_complete(sql_query())