asyncpg
asyncpg copied to clipboard
connection error
It is bit hard to figure out, which exceptions I should catch if I want to recover my application from connection errors.
So far
-
OSError
- when database is down -
CannotConnectNowError
when PostgreSQL is starting -
ConnectionDoesNotExistError
when connection is removed from connection pool -
InterfaceError
when message contains one of-
connection has been released back to the pool
-
the underlying connection is closed
-
It seems I should add one PostgresConnectionError
deriving classes as well? Anything else?
Can you share the code for the error classes you made @wrobell ? I am having the same problem as you are (catching connection errors) and I wonder how you resolved it
@fugacityengr Please take a look at catch_conn_error
function in https://gitlab.com/n23/n23/-/blob/master/n23/storage/pg/core.py. This logic serves me well for almost two years, now.
Thank you so much! Helped me a lot