🦉 Updates from OwlBot post-processor · googleapis/python-spanner@f04b0e1 · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit f04b0e1

Browse files
1 parent b45500d commit f04b0e1

File tree

5 files changed

+32
-27
lines changed

5 files changed

+32
-27
lines changed

‎google/cloud/spanner_v1/database.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ def __init__(
199199
pool.bind(self)
200200
self._session_manager = DatabaseSessionsManager(database=self, pool=pool)
201201

202-
203202
@classmethod
204203
def from_pb(cls, database_pb, instance, pool=None):
205204
"""Creates an instance of this class from a protobuf.
@@ -785,8 +784,8 @@ def execute_pdml():
785784
# re-raising the error.
786785
except NotImplementedError as exc:
787786
if (
788-
"Transaction type partitioned_dml not supported with multiplexed sessions"
789-
in str(exc)
787+
"Transaction type partitioned_dml not supported with multiplexed sessions"
788+
in str(exc)
790789
):
791790
self.session_options.disable_multiplexed(
792791
self.logger, TransactionType.PARTITIONED
@@ -1261,6 +1260,7 @@ def __init__(
12611260
):
12621261
# Move import here to avoid circular import
12631262
from google.cloud.spanner_v1.database import Database
1263+
12641264
if not isinstance(database, Database):
12651265
raise TypeError(
12661266
"{class_name} must receive an instance of {expected_class_name}. Received: {actual_class_name}".format(
@@ -1290,6 +1290,7 @@ def __enter__(self):
12901290
def __exit__(self, *ignored):
12911291
self._database._session_manager.put_session(self._session)
12921292

1293+
12931294
class BatchCheckout(object):
12941295
"""Context manager for using a batch from a database.
12951296
@@ -1978,4 +1979,3 @@ def _retry_on_aborted(func, retry_config):
19781979
"""
19791980
retry = retry_config.with_predicate(if_exception_type(Aborted))
19801981
return retry(func)
1981-

‎google/cloud/spanner_v1/database_sessions_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,4 @@ def _maintain_multiplexed_session(session_manager_ref) -> None:
256256
session_manager._disable_multiplexed_sessions()
257257
return
258258

259-
session_created_time = time.time()
259+
session_created_time = time.time()

‎google/cloud/spanner_v1/pool.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,3 @@ def begin_pending_transactions(self):
787787
while not self._pending_sessions.empty():
788788
session = self._pending_sessions.get()
789789
super(TransactionPingingPool, self).put(session)
790-
791-
792-
793-

‎google/cloud/spanner_v1/session_options.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ def use_multiplexed(self, transaction_type: TransactionType) -> bool:
6666
"""
6767

6868
if transaction_type is TransactionType.READ_ONLY:
69-
return (
70-
self._is_multiplexed_enabled[transaction_type]
71-
and self._getenv(self.ENV_VAR_ENABLE_MULTIPLEXED)
69+
return self._is_multiplexed_enabled[transaction_type] and self._getenv(
70+
self.ENV_VAR_ENABLE_MULTIPLEXED
7271
)
7372

7473
elif transaction_type is TransactionType.PARTITIONED:
@@ -80,7 +79,7 @@ def use_multiplexed(self, transaction_type: TransactionType) -> bool:
8079

8180
elif transaction_type is TransactionType.READ_WRITE:
8281
return False
83-
82+
8483
raise ValueError(f"Transaction type {transaction_type} is not supported.")
8584

8685
def disable_multiplexed(
@@ -104,11 +103,15 @@ def disable_multiplexed(
104103
if transaction_type is None:
105104
if logger:
106105
logger.warning(
107-
disable_multiplexed_log_msg_fstring.format(transaction_type_value="all")
106+
disable_multiplexed_log_msg_fstring.format(
107+
transaction_type_value="all"
108+
)
108109
)
109110
else:
110111
print(
111-
disable_multiplexed_log_msg_fstring.format(transaction_type_value="all")
112+
disable_multiplexed_log_msg_fstring.format(
113+
transaction_type_value="all"
114+
)
112115
)
113116
for transaction_type in TransactionType:
114117
self._is_multiplexed_enabled[transaction_type] = False
@@ -123,7 +126,9 @@ def disable_multiplexed(
123126
)
124127
else:
125128
print(
126-
disable_multiplexed_log_msg_fstring.format(transaction_type_value=transaction_type.value)
129+
disable_multiplexed_log_msg_fstring.format(
130+
transaction_type_value=transaction_type.value
131+
)
127132
)
128133
self._is_multiplexed_enabled[transaction_type] = False
129134
return
@@ -137,4 +142,4 @@ def _getenv(name: str) -> bool:
137142
considered false.
138143
"""
139144
env_var = os.getenv(name, "").lower().strip()
140-
return env_var in ["1", "true"]
145+
return env_var in ["1", "true"]

‎google/cloud/spanner_v1/snapshot.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def _restart_on_unavailable(
196196

197197
del item_buffer[:]
198198

199+
199200
def _handle_not_implemented_error(exception, database) -> None:
200201
"""Handles NotImplementedError for the database. If the error is due to unsupported
201202
partitioned operations with multiplexed sessions, disables multiplexed sessions for
@@ -212,10 +213,13 @@ def _handle_not_implemented_error(exception, database) -> None:
212213
exception
213214
):
214215
session_options = database.session_options
215-
session_options.disable_multiplexed(database.logger, TransactionType.PARTITIONED)
216+
session_options.disable_multiplexed(
217+
database.logger, TransactionType.PARTITIONED
218+
)
216219

217220
raise exception
218221

222+
219223
class _SnapshotBase(_SessionWrapper):
220224
"""Base class for Snapshot.
221225
@@ -614,7 +618,6 @@ def wrapped_restart(*args, **kwargs):
614618
return self._get_streamed_result_set(**get_streamed_result_set_args)
615619
return self._get_streamed_result_set(**get_streamed_result_set_args)
616620

617-
618621
def partition_read(
619622
self,
620623
table,
@@ -856,14 +859,14 @@ def attempt_tracking_method():
856859
return [partition.partition_token for partition in response.partitions]
857860

858861
def _get_streamed_result_set(
859-
self,
860-
method,
861-
request,
862-
metadata,
863-
trace_attributes,
864-
column_info,
865-
observability_options,
866-
lazy_decode,
862+
self,
863+
method,
864+
request,
865+
metadata,
866+
trace_attributes,
867+
column_info,
868+
observability_options,
869+
lazy_decode,
867870
):
868871
"""Returns the streamed result set for a read or execute SQL request with the given arguments."""
869872

@@ -901,6 +904,7 @@ def _get_streamed_result_set(
901904

902905
return StreamedResultSet(**streamed_result_set_args)
903906

907+
904908
class Snapshot(_SnapshotBase):
905909
"""Allow a set of reads / SQL statements with shared staleness.
906910

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.