From 5772b89f540527bc4286ea6b040b543ef1f21931 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 23 Sep 2021 15:38:58 +0500 Subject: [PATCH] fix: Added durable argument to transaction.atomic. It is implemented in django32. --- common/djangoapps/util/db.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/djangoapps/util/db.py b/common/djangoapps/util/db.py index 41d0763623..748b682f33 100644 --- a/common/djangoapps/util/db.py +++ b/common/djangoapps/util/db.py @@ -8,7 +8,7 @@ import random # TransactionManagementError used below actually *does* derive from the standard "Exception" class. # lint-amnesty, pylint: disable=bad-option-value, nonstandard-exception from contextlib import contextmanager - +import django from django.db import DEFAULT_DB_ALIAS, transaction # lint-amnesty, pylint: disable=unused-import from openedx.core.lib.cache_utils import get_cache @@ -52,10 +52,13 @@ class OuterAtomic(transaction.Atomic): """ ALLOW_NESTED = False - def __init__(self, using, savepoint, name=None, durable=False,): + def __init__(self, using, savepoint, name=None, durable=False): self.name = name self.durable = durable - super().__init__(using, savepoint, durable) + if django.VERSION >= (3, 1): + super().__init__(using, savepoint, durable) + else: + super().__init__(using, savepoint) def __enter__(self):