mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #19707 -- Reset transaction state after requests
This commit is contained in:
@@ -24,6 +24,21 @@ class TransactionManagementError(Exception):
|
||||
"""
|
||||
pass
|
||||
|
||||
def abort(using=None):
|
||||
"""
|
||||
Roll back any ongoing transactions and clean the transaction management
|
||||
state of the connection.
|
||||
|
||||
This method is to be used only in cases where using balanced
|
||||
leave_transaction_management() calls isn't possible. For example after a
|
||||
request has finished, the transaction state isn't known, yet the connection
|
||||
must be cleaned up for the next request.
|
||||
"""
|
||||
if using is None:
|
||||
using = DEFAULT_DB_ALIAS
|
||||
connection = connections[using]
|
||||
connection.abort()
|
||||
|
||||
def enter_transaction_management(managed=True, using=None):
|
||||
"""
|
||||
Enters transaction management for a running thread. It must be balanced with
|
||||
|
||||
Reference in New Issue
Block a user