Skip to content

Commit 4b8e11b

Browse files
Takashi Matsuobusunkim96
Takashi Matsuo
authored andcommitted
testing(automl): retry upon InternalServerError [(#4350)](GoogleCloudPlatform/python-docs-samples#4350)
fixes #4343
1 parent 28d13a6 commit 4b8e11b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/google-cloud-automl/samples/snippets/list_operation_status_test.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import os
1616

17+
import backoff
18+
from google.api_core.exceptions import InternalServerError
1719
import pytest
1820

1921
import list_operation_status
@@ -23,6 +25,11 @@
2325

2426
@pytest.mark.slow
2527
def test_list_operation_status(capsys):
26-
list_operation_status.list_operation_status(PROJECT_ID)
28+
# We saw 500 InternalServerError. Now we just retry few times.
29+
@backoff.on_exception(backoff.expo, InternalServerError, max_time=120)
30+
def run_sample():
31+
list_operation_status.list_operation_status(PROJECT_ID)
32+
33+
run_sample()
2734
out, _ = capsys.readouterr()
2835
assert "Operation details" in out

0 commit comments

Comments
 (0)