summaryrefslogtreecommitdiff
path: root/django/db/transaction.py
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-02-05 23:52:29 +0200
committerAnssi Kääriäinen <akaariai@gmail.com>2013-02-10 13:55:54 +0200
commita4e97cf315142e61bb4bc3ed8259b95d8586d09c (patch)
tree7f21b7043e9a05a2dae6d8c833f98cb68f1c7fc9 /django/db/transaction.py
parent0e18fb04bad99de237b5eb8ea4f9ff2f3cd147d3 (diff)
Fixed #19707 -- Reset transaction state after requests
Diffstat (limited to 'django/db/transaction.py')
-rw-r--r--django/db/transaction.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/django/db/transaction.py b/django/db/transaction.py
index f3ce2b2335..dd7e2f4dcb 100644
--- a/django/db/transaction.py
+++ b/django/db/transaction.py
@@ -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