Skip to content

Commit

Permalink
Add retry for DeadlineExceeded to 'test_bigtable_create_table' snippe…
Browse files Browse the repository at this point in the history
…t. (#8889)

Fixes #8480.
  • Loading branch information
mf2199 authored and tseaver committed Aug 7, 2019
1 parent 799c1e5 commit dd4c5a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bigtable/docs/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit dd4c5a1

Please sign in to comment.