Skip to content

Commit dede005

Browse files
committed
fix(cli, studio): don't retry on non request/http errors
1 parent 03d7440 commit dede005

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/datachain/remote/studio.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from urllib.parse import urlparse, urlunparse
1515

1616
import websockets
17+
from requests.exceptions import ConnectionError, HTTPError, Timeout
1718

1819
from datachain.config import Config
1920
from datachain.error import DataChainError
@@ -158,7 +159,7 @@ def _send_request_msgpack(
158159
message = content.get("message", "")
159160
return Response(response_data, ok, message)
160161

161-
@retry_with_backoff(retries=5)
162+
@retry_with_backoff(retries=3, errors=(HTTPError, ConnectionError, Timeout))
162163
def _send_request(
163164
self, route: str, data: dict[str, Any], method: Optional[str] = "POST"
164165
) -> Response[Any]:
@@ -188,7 +189,7 @@ def _send_request(
188189
)
189190
try:
190191
response.raise_for_status()
191-
except requests.exceptions.HTTPError:
192+
except HTTPError:
192193
if _is_server_error(response.status_code):
193194
# going to retry
194195
raise

src/datachain/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ def flatten(items):
271271
yield item
272272

273273

274-
def retry_with_backoff(retries=5, backoff_sec=1):
274+
def retry_with_backoff(retries=5, backoff_sec=1, errors=(Exception,)):
275275
def retry(f):
276276
def wrapper(*args, **kwargs):
277277
num_tried = 0
278278
while True:
279279
try:
280280
return f(*args, **kwargs)
281-
except Exception:
281+
except errors:
282282
if num_tried == retries:
283283
raise
284284
sleep = (

0 commit comments

Comments
 (0)