Skip to content

Commit

Permalink
Retry on duplicate bucket in persistent bucket get_or_create
Browse files Browse the repository at this point in the history
  • Loading branch information
kris-konina-reef committed Sep 17, 2024
1 parent 7d18983 commit 2c05f31
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/integration/persistent_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import backoff
from b2sdk.v2 import Bucket
from b2sdk.v2.exception import NonExistentBucket
from b2sdk.v2.exception import DuplicateBucketName, NonExistentBucket

PERSISTENT_BUCKET_NAME_PREFIX = "constst"

Expand Down Expand Up @@ -65,6 +65,12 @@ def get_persistent_bucket_name(b2_api: Api) -> str:
return f"{PERSISTENT_BUCKET_NAME_PREFIX}-{bucket_hash}" [:BUCKET_NAME_LENGTH]


@backoff.on_exception(
backoff.expo,
DuplicateBucketName,
max_tries=3,
jitter=backoff.full_jitter,
)
def get_or_create_persistent_bucket(b2_api: Api) -> Bucket:
bucket_name = get_persistent_bucket_name(b2_api)
try:
Expand Down

0 comments on commit 2c05f31

Please sign in to comment.