Использую pymysql, при длительном подключении и использовании соединения выдает ошибку
Ignoring exception in on_voice_state_update
Traceback (most recent call last):
File "/home/shandy_server2/.local/lib/python3.6/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 60, in on_voice_state_update
guild_voice_id = await get_voice_id(member.guild)
File "bot.py", line 198, in get_voice_id
cur.execute(f"SELECT channel FROM simple_voice.servers_data WHERE server_id = {guild.id};")
File "/home/shandy_server2/.local/lib/python3.6/site-packages/pymysql/cursors.py", line 148, in execute
result = self._query(query)
File "/home/shandy_server2/.local/lib/python3.6/site-packages/pymysql/cursors.py", line 310, in _query
conn.query(q)
File "/home/shandy_server2/.local/lib/python3.6/site-packages/pymysql/connections.py", line 547, in query
self._execute_command(COMMAND.COM_QUERY, sql)
File "/home/shandy_server2/.local/lib/python3.6/site-packages/pymysql/connections.py", line 793, in _execute_command
raise err.InterfaceError(0, "")
pymysql.err.InterfaceError: (0, '')
Код
@bot.event
async def on_voice_state_update(member, before, after):
# Удаление канала
guild_voice_id = await get_voice_id(member.guild)
# Проверка канала для удаления или выставления 0 id
for channel in channels_in_use:
if before.channel.id == channel:
if member.id == channels_in_use[before.channel.id]:
channels_in_use[before.channel.id] = 0
if not before.channel.members:
await before.channel.delete()
try:
del channels_in_use[before.channel.id]
except:
print("Как так то")
else:
pass
# Да
if after.channel == before.channel:
return
elif member.voice is None:
return
elif member.voice.channel.id == guild_voice_id:
channel = bot.get_channel(guild_voice_id)
category = channel.category
user_data = await get_user_preferences(member)
if user_data is None:
with con.cursor() as cur:
cur.execute(
f"INSERT INTO `simple_voice`.`users_data` (`user_id`, `name`, `limit`) VALUES ('{member.id}', 'Канал {member.display_name}', '0');")
created_channel = await category.create_voice_channel(name=f"Канал {member.display_name}",
user_limit=None)
else:
created_channel = await category.create_voice_channel(name=user_data[1], user_limit=user_data[2])
await member.move_to(channel=created_channel)
channels_in_use[created_channel.id] = member.id
Код кривой, но руки никак не дойдут, чтобы переписать :(