sql: do not try rollbacking if there's no connection anymore (#49622) #509

Merged
fpeters merged 1 commits from wip/49622-none-rollback into main 2023-08-11 00:31:41 +02:00
1 changed files with 4 additions and 2 deletions

View File

@ -384,8 +384,10 @@ def guard_postgres(func):
try:
return func(*args, **kwargs)
except psycopg2.Error:
get_publisher().capture_exception(sys.exc_info())
get_connection().rollback()
conn = get_connection()
if conn:
get_publisher().capture_exception(sys.exc_info())
conn.rollback()
raise
return f