Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/_topic_common/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def wrapper(rpc_state, response_pb, driver=None):


_shared_event_loop_lock = threading.Lock()
_shared_event_loop = None # type: Optional[asyncio.AbstractEventLoop]
_shared_event_loop: Optional[asyncio.AbstractEventLoop] = None


def _get_shared_event_loop() -> asyncio.AbstractEventLoop:
Expand Down
5 changes: 1 addition & 4 deletions ydb/aio/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
_scan_query_request_factory,
_wrap_scan_query_response,
BaseTxContext,
_allow_split_transaction,
)
from . import _utilities
from ydb import _apis, _session_impl
Expand Down Expand Up @@ -121,9 +120,7 @@ async def alter_table(
set_read_replicas_settings,
)

def transaction(
self, tx_mode=None, *, allow_split_transactions=_allow_split_transaction
):
def transaction(self, tx_mode=None, *, allow_split_transactions=None):
return TxContext(
self._driver,
self._state,
Expand Down
10 changes: 8 additions & 2 deletions ydb/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@


def global_allow_truncated_result(enabled: bool = True):
if convert._default_allow_truncated_result == enabled:
return

if enabled:
warnings.warn("Global allow truncated response is deprecated behaviour.")

convert._default_allow_truncated_result = enabled


def global_allow_split_transactions(enabled: bool):
if table._default_allow_split_transaction == enabled:
return

if enabled:
warnings.warn("Global allow truncated response is deprecated behaviour.")
warnings.warn("Global allow split transaction is deprecated behaviour.")

table._allow_split_transaction = enabled
table._default_allow_split_transaction = enabled
20 changes: 11 additions & 9 deletions ydb/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
except ImportError:
interceptor = None

_allow_split_transaction = False
_default_allow_split_transaction = False

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1181,9 +1181,7 @@ def execute_scheme(self, yql_text, settings=None):
pass

@abstractmethod
def transaction(
self, tx_mode=None, allow_split_transactions=_allow_split_transaction
):
def transaction(self, tx_mode=None, allow_split_transactions=None):
pass

@abstractmethod
Expand Down Expand Up @@ -1687,9 +1685,7 @@ def execute_scheme(self, yql_text, settings=None):
self._state.endpoint,
)

def transaction(
self, tx_mode=None, allow_split_transactions=_allow_split_transaction
):
def transaction(self, tx_mode=None, allow_split_transactions=None):
return TxContext(
self._driver,
self._state,
Expand Down Expand Up @@ -2226,7 +2222,7 @@ def __init__(
session,
tx_mode=None,
*,
allow_split_transactions=_allow_split_transaction
allow_split_transactions=None
):
"""
An object that provides a simple transaction context manager that allows statements execution
Expand Down Expand Up @@ -2413,7 +2409,13 @@ def _check_split(self, allow=""):
Deny all operaions with transaction after commit/rollback.
Exception: double commit and double rollbacks, because it is safe
"""
if self._allow_split_transactions:
allow_split_transaction = (
self._allow_split_transactions
if self._allow_split_transactions is not None
else _default_allow_split_transaction
)

if allow_split_transaction:
return

if self._finished != "" and self._finished != allow:
Expand Down