Skip to content

Commit ea0823f

Browse files
committed
Wire up and revert some prints
1 parent f435747 commit ea0823f

File tree

6 files changed

+23
-32
lines changed

6 files changed

+23
-32
lines changed

google/cloud/spanner_v1/_helpers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,12 @@ def inject_retry_header_control(api):
752752

753753
orig_getattribute = getattr(target, "__getattribute__")
754754

755-
def patched_getattribute(*args, **kwargs):
756-
attr = orig_getattribute(*args, **kwargs)
755+
def patched_getattribute(obj, key, *args, **kwargs):
756+
if key.startswith("_"):
757+
return orig_getattribute(obj, key, *args, **kwargs)
758+
759+
attr = orig_getattribute(obj, key, *args, **kwargs)
760+
print("args", args, "attr.dir", dir(attr))
757761

758762
# 0. If we already patched it, we can return immediately.
759763
if getattr(attr, "_patched", None) is not None:

google/cloud/spanner_v1/batch.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,15 @@ def commit(
250250
observability_options=observability_options,
251251
metadata=metadata,
252252
), MetricsCapture():
253-
attempt = AtomicCounter(0)
254-
next_nth_request = database._next_nth_request
255-
256-
all_metadata = database.metadata_with_request_id(
257-
next_nth_request,
258-
attempt.increment(),
259-
metadata,
260-
)
261253
method = functools.partial(
262254
api.commit,
263255
request=request,
264-
metadata=all_metadata,
256+
metadata=database.metadata_with_request_id(
257+
database._next_nth_request,
258+
1,
259+
metadata,
260+
),
265261
)
266-
267262
deadline = time.time() + kwargs.get(
268263
"timeout_secs", DEFAULT_RETRY_TIMEOUT_SECS
269264
)
@@ -382,18 +377,15 @@ def batch_write(self, request_options=None, exclude_txn_from_change_streams=Fals
382377
observability_options=observability_options,
383378
metadata=metadata,
384379
), MetricsCapture():
385-
next_nth_request = database._next_nth_request
386-
all_metadata = database.metadata_with_request_id(
387-
next_nth_request,
388-
0,
389-
metadata,
390-
)
391380
method = functools.partial(
392381
api.batch_write,
393382
request=request,
394-
metadata=all_metadata,
383+
metadata=database.metadata_with_request_id(
384+
database._next_nth_request,
385+
1,
386+
metadata,
387+
),
395388
)
396-
397389
response = _retry(
398390
method,
399391
allowed_exceptions={

google/cloud/spanner_v1/database.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ def execute_pdml():
792792
query_options=query_options,
793793
request_options=request_options,
794794
)
795-
796795
method = functools.partial(
797796
api.execute_streaming_sql,
798797
metadata=self.metadata_with_request_id(

google/cloud/spanner_v1/pool.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
"""Pools managing shared Session objects."""
1616

1717
import datetime
18-
import random
1918
import queue
2019
import time
2120

2221
from google.cloud.exceptions import NotFound
23-
from google.api_core.exceptions import ServiceUnavailable
2422
from google.cloud.spanner_v1 import BatchCreateSessionsRequest
2523
from google.cloud.spanner_v1 import Session
2624
from google.cloud.spanner_v1._helpers import (
@@ -257,7 +255,6 @@ def bind(self, database):
257255
f"Creating {request.session_count} sessions",
258256
span_event_attributes,
259257
)
260-
261258
resp = api.batch_create_sessions(
262259
request=request,
263260
metadata=database.metadata_with_request_id(

google/cloud/spanner_v1/services/spanner/transports/grpc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,7 @@ def batch_create_sessions(
413413
request_serializer=spanner.BatchCreateSessionsRequest.serialize,
414414
response_deserializer=spanner.BatchCreateSessionsResponse.deserialize,
415415
)
416-
fn = self._stubs["batch_create_sessions"]
417-
print("\033[32minvoking batch_create_sessionhex_id", hex(id(fn)), "\033[00m")
418-
return fn
416+
return self._stubs["batch_create_sessions"]
419417

420418
@property
421419
def get_session(self) -> Callable[[spanner.GetSessionRequest], spanner.Session]:

google/cloud/spanner_v1/session.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,6 @@ def exists(self):
207207
)
208208
)
209209

210-
all_metadata = database.metadata_with_request_id(
211-
database._next_nth_request, 1, metadata
212-
)
213-
214210
observability_options = getattr(self._database, "observability_options", None)
215211
with trace_call(
216212
"CloudSpanner.GetSession",
@@ -219,7 +215,12 @@ def exists(self):
219215
metadata=metadata,
220216
) as span, MetricsCapture():
221217
try:
222-
api.get_session(name=self.name, metadata=all_metadata)
218+
api.get_session(
219+
name=self.name,
220+
metadata=database.metadata_with_request_id(
221+
database._next_nth_request, 1, metadata
222+
),
223+
)
223224
if span:
224225
span.set_attribute("session_found", True)
225226
except NotFound:

0 commit comments

Comments
 (0)