Skip to content

Commit

Permalink
updated sync code
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Nov 28, 2024
1 parent 49c7059 commit 081a234
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ def __init__(
client: bigtable client
instance_id: id of the instance on which the query is executed
request_body: dict representing the body of the ExecuteQueryRequest
attempt_timeout: the time budget for the entire operation, in seconds.
Failed requests will be retried within the budget.
Defaults to 600 seconds.
operation_timeout: the time budget for an individual network request, in seconds.
attempt_timeout: the time budget for an individual network request, in seconds.
If it takes longer than this time to complete, the request will be cancelled with
a DeadlineExceeded exception, and a retry will be attempted.
Defaults to the 20 seconds. If None, defaults to operation_timeout.
operation_timeout: the time budget for the entire operation, in seconds.
Failed requests will be retried within the budget
req_metadata: metadata used while sending the gRPC request
retryable_excs: a list of errors that will be retried if encountered.
Raises:
Expand Down
2 changes: 1 addition & 1 deletion tests/system/data/test_system_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TestSystem:
@pytest.fixture(scope="session")
def client(self):
project = os.getenv("GOOGLE_CLOUD_PROJECT") or None
with CrossSync._Sync_Impl.DataClient(project=project, pool_size=4) as client:
with CrossSync._Sync_Impl.DataClient(project=project) as client:
yield client

@pytest.fixture(scope="session")
Expand Down
21 changes: 12 additions & 9 deletions tests/unit/data/_sync_autogen/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,18 @@ def test__manage_channel_sleeps(self, refresh_interval, num_cycles, expected_sle
]
client = self._make_client(project="project-id")
client.transport._grpc_channel = channel
try:
if refresh_interval is not None:
client._manage_channel(
refresh_interval, refresh_interval, grace_period=0
)
else:
client._manage_channel(grace_period=0)
except asyncio.CancelledError:
pass
with mock.patch.object(
client.transport, "create_channel", CrossSync._Sync_Impl.Mock
):
try:
if refresh_interval is not None:
client._manage_channel(
refresh_interval, refresh_interval, grace_period=0
)
else:
client._manage_channel(grace_period=0)
except asyncio.CancelledError:
pass
assert sleep.call_count == num_cycles
total_sleep = sum([call[0][1] for call in sleep.call_args_list])
assert (
Expand Down

0 comments on commit 081a234

Please sign in to comment.