|
27 | 27 | except ImportError: |
28 | 28 | interceptor = None |
29 | 29 |
|
30 | | -_allow_split_transaction = False |
| 30 | +_default_allow_split_transaction = False |
31 | 31 |
|
32 | 32 | logger = logging.getLogger(__name__) |
33 | 33 |
|
@@ -1181,9 +1181,7 @@ def execute_scheme(self, yql_text, settings=None): |
1181 | 1181 | pass |
1182 | 1182 |
|
1183 | 1183 | @abstractmethod |
1184 | | - def transaction( |
1185 | | - self, tx_mode=None, allow_split_transactions=_allow_split_transaction |
1186 | | - ): |
| 1184 | + def transaction(self, tx_mode=None, allow_split_transactions=None): |
1187 | 1185 | pass |
1188 | 1186 |
|
1189 | 1187 | @abstractmethod |
@@ -1687,9 +1685,7 @@ def execute_scheme(self, yql_text, settings=None): |
1687 | 1685 | self._state.endpoint, |
1688 | 1686 | ) |
1689 | 1687 |
|
1690 | | - def transaction( |
1691 | | - self, tx_mode=None, allow_split_transactions=_allow_split_transaction |
1692 | | - ): |
| 1688 | + def transaction(self, tx_mode=None, allow_split_transactions=None): |
1693 | 1689 | return TxContext( |
1694 | 1690 | self._driver, |
1695 | 1691 | self._state, |
@@ -2226,7 +2222,7 @@ def __init__( |
2226 | 2222 | session, |
2227 | 2223 | tx_mode=None, |
2228 | 2224 | *, |
2229 | | - allow_split_transactions=_allow_split_transaction |
| 2225 | + allow_split_transactions=None |
2230 | 2226 | ): |
2231 | 2227 | """ |
2232 | 2228 | An object that provides a simple transaction context manager that allows statements execution |
@@ -2413,7 +2409,13 @@ def _check_split(self, allow=""): |
2413 | 2409 | Deny all operaions with transaction after commit/rollback. |
2414 | 2410 | Exception: double commit and double rollbacks, because it is safe |
2415 | 2411 | """ |
2416 | | - if self._allow_split_transactions: |
| 2412 | + allow_split_transaction = ( |
| 2413 | + self._allow_split_transactions |
| 2414 | + if self._allow_split_transactions is not None |
| 2415 | + else _default_allow_split_transaction |
| 2416 | + ) |
| 2417 | + |
| 2418 | + if allow_split_transaction: |
2417 | 2419 | return |
2418 | 2420 |
|
2419 | 2421 | if self._finished != "" and self._finished != allow: |
|
0 commit comments