diff --git a/bigtable/docs/snippets.py b/bigtable/docs/snippets.py index 7f4071b41fd8..1119b3b6bd90 100644 --- a/bigtable/docs/snippets.py +++ b/bigtable/docs/snippets.py @@ -395,6 +395,8 @@ def test_bigtable_update_cluster(): def test_bigtable_create_table(): # [START bigtable_create_table] + from google.api_core import exceptions + from google.api_core import retry from google.cloud.bigtable import Client from google.cloud.bigtable import column_family @@ -403,7 +405,13 @@ def test_bigtable_create_table(): table = instance.table("table_my") # Define the GC policy to retain only the most recent 2 versions. max_versions_rule = column_family.MaxVersionsGCRule(2) - table.create(column_families={"cf1": max_versions_rule}) + + # Could include other retriable exception types + # Could configure deadline, etc. + predicate_504 = retry.if_exception_type(exceptions.DeadlineExceeded) + retry_504 = retry.Retry(predicate_504) + + retry_504(table.create)(column_families={"cf1": max_versions_rule}) # [END bigtable_create_table] try: