Skip to content

Commit d120d65

Browse files
mf2199tseaver
authored andcommitted
Add retry for DeadlineExceeded to 'test_bigtable_create_table' snippet. (#8889)
Fixes #8480.
1 parent 7e1e574 commit d120d65

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/google-cloud-bigtable/docs/snippets.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ def test_bigtable_update_cluster():
395395

396396
def test_bigtable_create_table():
397397
# [START bigtable_create_table]
398+
from google.api_core import exceptions
399+
from google.api_core import retry
398400
from google.cloud.bigtable import Client
399401
from google.cloud.bigtable import column_family
400402

@@ -403,7 +405,13 @@ def test_bigtable_create_table():
403405
table = instance.table("table_my")
404406
# Define the GC policy to retain only the most recent 2 versions.
405407
max_versions_rule = column_family.MaxVersionsGCRule(2)
406-
table.create(column_families={"cf1": max_versions_rule})
408+
409+
# Could include other retriable exception types
410+
# Could configure deadline, etc.
411+
predicate_504 = retry.if_exception_type(exceptions.DeadlineExceeded)
412+
retry_504 = retry.Retry(predicate_504)
413+
414+
retry_504(table.create)(column_families={"cf1": max_versions_rule})
407415
# [END bigtable_create_table]
408416

409417
try:

0 commit comments

Comments
 (0)