Skip to content

Commit 7069885

Browse files
committed
Fixed issue django-commons#230 -- prevent crash when transaction is in error state
fix for ticket django-commons#230 if isolation_level is looked up while transaction is in an error state, an exception is thrown, which eats up the original exception that is never shown
1 parent 62f4455 commit 7069885

File tree

1 file changed

+2
-1
lines changed
  • debug_toolbar/utils/tracking

1 file changed

+2
-1
lines changed

debug_toolbar/utils/tracking/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ def execute(self, sql, params=()):
146146
}
147147

148148
if engine == 'psycopg2':
149+
from psycopg2.extensions import TRANSACTION_STATUS_INERROR
149150
params.update({
150151
'trans_id': self.logger.get_transaction_id(alias),
151152
'trans_status': conn.get_transaction_status(),
152-
'iso_level': conn.isolation_level,
153+
'iso_level': conn.isolation_level if not conn.get_transaction_status() == TRANSACTION_STATUS_INERROR else "",
153154
'encoding': conn.encoding,
154155
})
155156

0 commit comments

Comments
 (0)