Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
docs: adding backoff to quickstart test (#135)
Browse files Browse the repository at this point in the history
* adding backoff to quickstart test

* fixing lint
  • Loading branch information
bradmiro committed Mar 2, 2021
1 parent 6231361 commit a22df4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion samples/snippets/quickstart/quickstart_test.py
Expand Up @@ -15,6 +15,8 @@
import os
import uuid

import backoff
from google.api_core.exceptions import ServiceUnavailable
from google.cloud import dataproc_v1 as dataproc
from google.cloud import storage
import pytest
Expand All @@ -39,7 +41,14 @@
@pytest.fixture(autouse=True)
def setup_teardown():
storage_client = storage.Client()
bucket = storage_client.create_bucket(STAGING_BUCKET)

@backoff.on_exception(backoff.expo,
ServiceUnavailable,
max_tries=5)
def create_bucket():
return storage_client.create_bucket(STAGING_BUCKET)

bucket = create_bucket()
blob = bucket.blob(JOB_FILE_NAME)
blob.upload_from_string(SORT_CODE)

Expand Down
2 changes: 2 additions & 0 deletions samples/snippets/requirements.txt
@@ -1,3 +1,5 @@

backoff==1.10.0
grpcio==1.36.0
google-auth==1.27.0
google-auth-httplib2==0.0.4
Expand Down

0 comments on commit a22df4c

Please sign in to comment.