|
83 | 83 | from google.cloud.bigtable_v2.services.bigtable.transports import ( |
84 | 84 | BigtableGrpcAsyncIOTransport as TransportType, |
85 | 85 | ) |
86 | | - from google.cloud.bigtable.data._async.mutations_batcher import ( |
87 | | - MutationsBatcherAsync, |
88 | | - _MB_SIZE, |
89 | | - ) |
90 | | - from google.cloud.bigtable.data.execute_query._async.execute_query_iterator import ( |
91 | | - ExecuteQueryIteratorAsync, |
92 | | - ) |
93 | | - |
| 86 | + from google.cloud.bigtable.data._async.mutations_batcher import _MB_SIZE |
94 | 87 | else: |
95 | 88 | from grpc import insecure_channel |
96 | 89 | from google.cloud.bigtable_v2.services.bigtable.transports import BigtableGrpcTransport as TransportType # type: ignore |
97 | | - from google.cloud.bigtable.data._sync_autogen.mutations_batcher import ( # noqa: F401 |
98 | | - MutationsBatcher, |
99 | | - _MB_SIZE, |
100 | | - ) |
101 | | - from google.cloud.bigtable.data.execute_query._sync_autogen.execute_query_iterator import ( # noqa: F401 |
102 | | - ExecuteQueryIterator, |
103 | | - ) |
104 | 90 |
|
105 | 91 |
|
106 | 92 | if TYPE_CHECKING: |
107 | 93 | from google.cloud.bigtable.data._helpers import RowKeySamples |
108 | 94 | from google.cloud.bigtable.data._helpers import ShardedQuery |
109 | 95 |
|
| 96 | + if CrossSync.is_async: |
| 97 | + from google.cloud.bigtable.data._async.mutations_batcher import ( |
| 98 | + MutationsBatcherAsync, |
| 99 | + ) |
| 100 | + from google.cloud.bigtable.data.execute_query._async.execute_query_iterator import ( |
| 101 | + ExecuteQueryIteratorAsync, |
| 102 | + ) |
| 103 | + |
| 104 | + |
110 | 105 | __CROSS_SYNC_OUTPUT__ = "google.cloud.bigtable.data._sync_autogen.client" |
111 | 106 |
|
112 | 107 |
|
@@ -372,8 +367,8 @@ async def _manage_channel( |
372 | 367 | await old_channel.close(grace_period) |
373 | 368 | else: |
374 | 369 | if grace_period: |
375 | | - self._is_closed.wait(grace_period) |
376 | | - old_channel.close() |
| 370 | + self._is_closed.wait(grace_period) # type: ignore |
| 371 | + old_channel.close() # type: ignore |
377 | 372 | # subtract thed time spent waiting for the channel to be replaced |
378 | 373 | next_refresh = random.uniform(refresh_interval_min, refresh_interval_max) |
379 | 374 | next_sleep = max(next_refresh - (time.monotonic() - start_timestamp), 0) |
@@ -421,7 +416,7 @@ async def _register_instance( |
421 | 416 | } |
422 | 417 | ) |
423 | 418 | async def _remove_instance_registration( |
424 | | - self, instance_id: str, owner: TableAsync | ExecuteQueryIteratorAsync |
| 419 | + self, instance_id: str, owner: TableAsync | "ExecuteQueryIteratorAsync" |
425 | 420 | ) -> bool: |
426 | 421 | """ |
427 | 422 | Removes an instance from the client's registered instances, to prevent |
@@ -585,7 +580,7 @@ async def execute_query( |
585 | 580 | "proto_format": {}, |
586 | 581 | } |
587 | 582 |
|
588 | | - return ExecuteQueryIteratorAsync( |
| 583 | + return CrossSync.ExecuteQueryIterator( |
589 | 584 | self, |
590 | 585 | instance_id, |
591 | 586 | app_profile_id, |
@@ -1132,7 +1127,7 @@ def mutations_batcher( |
1132 | 1127 | batch_attempt_timeout: float | None | TABLE_DEFAULT = TABLE_DEFAULT.MUTATE_ROWS, |
1133 | 1128 | batch_retryable_errors: Sequence[type[Exception]] |
1134 | 1129 | | TABLE_DEFAULT = TABLE_DEFAULT.MUTATE_ROWS, |
1135 | | - ) -> MutationsBatcherAsync: |
| 1130 | + ) -> "MutationsBatcherAsync": |
1136 | 1131 | """ |
1137 | 1132 | Returns a new mutations batcher instance. |
1138 | 1133 |
|
|
0 commit comments