This replaces use of config.conn with a call to await database.config.get_connection() which will establish a connection if there is no connection yet or reestablish the connection if it is closed.
This should fix the issue that comes up occasionally, eg:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/application_command.py", line 863, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "/app/modules/course_management/cog.py", line 60, in delete_course
await course_deleter.delete_course(interaction, channel)
File "/app/modules/course_management/course_deleter.py", line 14, in delete_course
await __delete_from_database(channel.id)
File "/app/modules/course_management/course_deleter.py", line 31, in __delete_from_database
await sql.delete("categories", channel=channel_id)
File "/app/database/sql/delete.py", line 19, in delete
async with config.conn.transaction():
File "/app/.heroku/python/lib/python3.10/site-packages/asyncpg/connection.py", line 274, in transaction
self._check_open()
File "/app/.heroku/python/lib/python3.10/site-packages/asyncpg/connection.py", line 1399, in _check_open
raise exceptions.InterfaceError('connection is closed')
asyncpg.exceptions._base.InterfaceError: connection is closed
Current workaround is restarting the bot every time it happens. This should avoid having to that.
This replaces use of
config.conn
with a call toawait database.config.get_connection()
which will establish a connection if there is no connection yet or reestablish the connection if it is closed.This should fix the issue that comes up occasionally, eg:
Current workaround is restarting the bot every time it happens. This should avoid having to that.