Skip to content

Commit b966b7a

Browse files
author
Val Brodsky
committed
Replace backoff with google.api_core.retry
1 parent 230341e commit b966b7a

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

labelbox/schema/annotation_import.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66
from typing import Any, BinaryIO, Dict, List, Union, TYPE_CHECKING, cast
77

8-
import backoff
8+
from google.api_core import retry
99
from labelbox import parser
1010
import requests
1111
from tqdm import tqdm # type: ignore
@@ -109,12 +109,9 @@ def wait_until_done(self,
109109
pbar.update(100 - pbar.n)
110110
pbar.close()
111111

112-
@backoff.on_exception(
113-
backoff.expo,
114-
(labelbox.exceptions.ApiLimitError, labelbox.exceptions.TimeoutError,
115-
labelbox.exceptions.NetworkError),
116-
max_tries=10,
117-
jitter=None)
112+
@retry.Retry(predicate=retry.if_exception_type(
113+
labelbox.exceptions.ApiLimitError, labelbox.exceptions.TimeoutError,
114+
labelbox.exceptions.NetworkError))
118115
def __backoff_refresh(self) -> None:
119116
self.refresh()
120117

labelbox/schema/bulk_import_request.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
from pathlib import Path
88
import pydantic
9-
import backoff
9+
from google.api_core import retry
1010
from labelbox import parser
1111
import requests
1212
from pydantic import BaseModel, root_validator, validator
@@ -197,11 +197,9 @@ def wait_until_done(self, sleep_time_seconds: int = 5) -> None:
197197
time.sleep(sleep_time_seconds)
198198
self.__exponential_backoff_refresh()
199199

200-
@backoff.on_exception(
201-
backoff.expo, (lb_exceptions.ApiLimitError, lb_exceptions.TimeoutError,
202-
lb_exceptions.NetworkError),
203-
max_tries=10,
204-
jitter=None)
200+
@retry.Retry(predicate=retry.if_exception_type(lb_exceptions.ApiLimitError,
201+
lb_exceptions.TimeoutError,
202+
lb_exceptions.NetworkError))
205203
def __exponential_backoff_refresh(self) -> None:
206204
self.refresh()
207205

0 commit comments

Comments
 (0)