|
14 | 14 |
|
15 | 15 | """Wrapper for Cloud Spanner Session objects.""" |
16 | 16 | __CROSS_SYNC_OUTPUT__ = "google.cloud.spanner_v1.session" |
17 | | -from datetime import datetime |
| 17 | +from datetime import datetime, timezone |
18 | 18 | from functools import total_ordering |
19 | 19 | import time |
20 | 20 | from typing import MutableMapping, Optional |
|
23 | 23 | from google.api_core.gapic_v1 import method |
24 | 24 |
|
25 | 25 | from google.cloud.aio._cross_sync import CrossSync |
26 | | -from google.cloud.spanner_v1 import CreateSessionRequest, ExecuteSqlRequest |
| 26 | +from google.cloud.spanner_v1.types.spanner import CreateSessionRequest |
| 27 | +from google.cloud.spanner_v1.types.spanner import ExecuteSqlRequest |
| 28 | +from google.cloud.spanner_v1._async._helpers import _delay_until_retry |
27 | 29 | from google.cloud.spanner_v1._async.batch import Batch |
28 | 30 | from google.cloud.spanner_v1._async.snapshot import Snapshot |
29 | 31 | from google.cloud.spanner_v1._async.transaction import Transaction |
30 | 32 | from google.cloud.spanner_v1._helpers import ( |
31 | | - _delay_until_retry, |
32 | 33 | _get_retry_delay, |
33 | 34 | _metadata_with_leader_aware_routing, |
34 | 35 | _metadata_with_prefix, |
@@ -77,7 +78,7 @@ def __init__(self, database, labels=None, database_role=None, is_multiplexed=Fal |
77 | 78 | self._labels: MutableMapping[str, str] = labels |
78 | 79 | self._database_role: Optional[str] = database_role |
79 | 80 | self._is_multiplexed: bool = is_multiplexed |
80 | | - self._last_use_time: datetime = datetime.utcnow() |
| 81 | + self._last_use_time: datetime = datetime.now(timezone.utc) |
81 | 82 |
|
82 | 83 | @property |
83 | 84 | def _resource_info(self): |
@@ -393,7 +394,7 @@ async def read(self, table, columns, keyset, index="", limit=0, column_info=None |
393 | 394 | :rtype: :class:`~google.cloud.spanner_v1.streamed.StreamedResultSet` |
394 | 395 | :returns: a result set instance which can be used to consume rows. |
395 | 396 | """ |
396 | | - return self.snapshot().read( |
| 397 | + return await self.snapshot().read( |
397 | 398 | table, columns, keyset, index, limit, column_info=column_info |
398 | 399 | ) |
399 | 400 |
|
@@ -460,7 +461,7 @@ async def execute_sql( |
460 | 461 | :rtype: :class:`~google.cloud.spanner_v1.streamed.StreamedResultSet` |
461 | 462 | :returns: a result set instance which can be used to consume rows. |
462 | 463 | """ |
463 | | - return self.snapshot().execute_sql( |
| 464 | + return await self.snapshot().execute_sql( |
464 | 465 | sql, |
465 | 466 | params, |
466 | 467 | param_types, |
@@ -599,7 +600,7 @@ async def run_in_transaction(self, func, *args, **kw): |
599 | 600 | "Transaction was aborted in user operation, retrying", |
600 | 601 | attributes, |
601 | 602 | ) |
602 | | - _delay_until_retry( |
| 603 | + await _delay_until_retry( |
603 | 604 | exc, |
604 | 605 | deadline, |
605 | 606 | attempts, |
@@ -645,7 +646,7 @@ async def run_in_transaction(self, func, *args, **kw): |
645 | 646 | "Transaction was aborted during commit, retrying", |
646 | 647 | attributes, |
647 | 648 | ) |
648 | | - _delay_until_retry( |
| 649 | + await _delay_until_retry( |
649 | 650 | exc, |
650 | 651 | deadline, |
651 | 652 | attempts, |
|
0 commit comments