fix(bot): 🐛 Messages not being flushed to the DB after asyncpg.exceptions.InterfaceError.
This commit is contained in:
@@ -143,7 +143,10 @@ class Calls(base.Cog):
|
|||||||
await models.Message.bulk_create(message_rows, batch_size=500)
|
await models.Message.bulk_create(message_rows, batch_size=500)
|
||||||
break
|
break
|
||||||
|
|
||||||
except asyncpg.exceptions.DeadlockDetectedError:
|
except (
|
||||||
|
asyncpg.exceptions.PostgresError,
|
||||||
|
asyncpg.exceptions.InterfaceError,
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
@@ -153,7 +156,10 @@ class Calls(base.Cog):
|
|||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
except asyncpg.exceptions.DeadlockDetectedError:
|
except (
|
||||||
|
asyncpg.exceptions.PostgresError,
|
||||||
|
asyncpg.exceptions.InterfaceError,
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@commands.command(aliases=["c"])
|
@commands.command(aliases=["c"])
|
||||||
@@ -950,8 +956,7 @@ class Calls(base.Cog):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
message_replies = await redis.hget(
|
message_replies = await redis.hget(
|
||||||
constants.CALL_MESSAGE_REPLIES_TEMPLATE % channel.call_id,
|
constants.CALL_MESSAGE_REPLIES_TEMPLATE % channel.call_id, message.id
|
||||||
message.id
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if message_replies is None:
|
if message_replies is None:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import discord
|
|||||||
from discord import errors
|
from discord import errors
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
|
import tortoise
|
||||||
from tortoise import transactions, expressions
|
from tortoise import transactions, expressions
|
||||||
|
|
||||||
from payphone import bot
|
from payphone import bot
|
||||||
@@ -301,6 +302,8 @@ class Mods(base.Cog):
|
|||||||
|
|
||||||
await self.bot.get_cog("Calls").flush_messages()
|
await self.bot.get_cog("Calls").flush_messages()
|
||||||
|
|
||||||
|
await tortoise.Tortoise.close_connections()
|
||||||
|
|
||||||
await ctx.send("⚡ Messages were flushed, payphone will shut down.")
|
await ctx.send("⚡ Messages were flushed, payphone will shut down.")
|
||||||
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ from payphone.core import config
|
|||||||
async def init() -> None:
|
async def init() -> None:
|
||||||
"""Initialize the database and it's connections."""
|
"""Initialize the database and it's connections."""
|
||||||
|
|
||||||
|
await tortoise.Tortoise.close_connections()
|
||||||
|
|
||||||
await tortoise.Tortoise.init(config.TORTOISE_ORM, use_tz=True)
|
await tortoise.Tortoise.init(config.TORTOISE_ORM, use_tz=True)
|
||||||
|
|
||||||
await tortoise.Tortoise.generate_schemas(safe=True)
|
await tortoise.Tortoise.generate_schemas(safe=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user