Skip to content

Commit 9c8950b

Browse files
authored
Merge pull request #235 V3 fix global behavior
2 parents a90394b + 88defe3 commit 9c8950b

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

ydb/aio/table.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
_scan_query_request_factory,
1414
_wrap_scan_query_response,
1515
BaseTxContext,
16-
_allow_split_transaction,
1716
)
1817
from . import _utilities
1918
from ydb import _apis, _session_impl
@@ -121,9 +120,7 @@ async def alter_table(
121120
set_read_replicas_settings,
122121
)
123122

124-
def transaction(
125-
self, tx_mode=None, *, allow_split_transactions=_allow_split_transaction
126-
):
123+
def transaction(self, tx_mode=None, *, allow_split_transactions=None):
127124
return TxContext(
128125
self._driver,
129126
self._state,

ydb/global_settings.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@
55

66

77
def global_allow_truncated_result(enabled: bool = True):
8+
if convert._default_allow_truncated_result == enabled:
9+
return
10+
811
if enabled:
912
warnings.warn("Global allow truncated response is deprecated behaviour.")
1013

1114
convert._default_allow_truncated_result = enabled
1215

1316

1417
def global_allow_split_transactions(enabled: bool):
18+
if table._default_allow_split_transaction == enabled:
19+
return
20+
1521
if enabled:
16-
warnings.warn("Global allow truncated response is deprecated behaviour.")
22+
warnings.warn("Global allow split transaction is deprecated behaviour.")
1723

18-
table._allow_split_transaction = enabled
24+
table._default_allow_split_transaction = enabled

ydb/table.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
except ImportError:
2828
interceptor = None
2929

30-
_allow_split_transaction = False
30+
_default_allow_split_transaction = False
3131

3232
logger = logging.getLogger(__name__)
3333

@@ -1181,9 +1181,7 @@ def execute_scheme(self, yql_text, settings=None):
11811181
pass
11821182

11831183
@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):
11871185
pass
11881186

11891187
@abstractmethod
@@ -1687,9 +1685,7 @@ def execute_scheme(self, yql_text, settings=None):
16871685
self._state.endpoint,
16881686
)
16891687

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):
16931689
return TxContext(
16941690
self._driver,
16951691
self._state,
@@ -2226,7 +2222,7 @@ def __init__(
22262222
session,
22272223
tx_mode=None,
22282224
*,
2229-
allow_split_transactions=_allow_split_transaction
2225+
allow_split_transactions=None
22302226
):
22312227
"""
22322228
An object that provides a simple transaction context manager that allows statements execution
@@ -2413,7 +2409,13 @@ def _check_split(self, allow=""):
24132409
Deny all operaions with transaction after commit/rollback.
24142410
Exception: double commit and double rollbacks, because it is safe
24152411
"""
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:
24172419
return
24182420

24192421
if self._finished != "" and self._finished != allow:

0 commit comments

Comments
 (0)