Skip to content

Commit

Permalink
wrap some datapath insert/update HTTP exceptions in datapath-specific…
Browse files Browse the repository at this point in the history
… exception

For compatibility with existing clients, continue to wrap the same HTTP error code
range in a datapath exception
  • Loading branch information
karlcz committed Aug 26, 2024
1 parent 3344f9b commit 34f758f
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions deriva/core/datapath.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,16 +1016,23 @@ def results_func(ignore1, ignore2, ignore3):
max_batch_rows=max_batch_rows,
max_batch_bytes=max_batch_bytes
):
if retry_safe:
resp = _request_with_retry(
lambda: request_func(batch),
retry_codes=retry_codes,
backoff_factor=backoff_factor,
max_attempts=max_attempts
)
else:
resp = request_func(batch)
results.extend(resp.json())
try:
if retry_safe:
resp = _request_with_retry(
lambda: request_func(batch),
retry_codes=retry_codes,
backoff_factor=backoff_factor,
max_attempts=max_attempts
)
else:
resp = request_func(batch)
results.extend(resp.json())
except HTTPError as e:
logger.debug(e.response.text)
if 400 <= e.response.status_code < 500:
raise DataPathException(_http_error_message(e), e)
else:
raise e
return results

result = _ResultSet(self.path.uri, results_func)
Expand Down Expand Up @@ -1102,13 +1109,20 @@ def results_func(ignore1, ignore2, ignore3):
max_batch_rows=max_batch_rows,
max_batch_bytes=max_batch_bytes
):
resp = _request_with_retry(
lambda: request_func(batch),
retry_codes=retry_codes,
backoff_factor=backoff_factor,
max_attempts=max_attempts
)
results.extend(resp.json())
try:
resp = _request_with_retry(
lambda: request_func(batch),
retry_codes=retry_codes,
backoff_factor=backoff_factor,
max_attempts=max_attempts
)
results.extend(resp.json())
except HTTPError as e:
logger.debug(e.response.text)
if 400 <= e.response.status_code < 500:
raise DataPathException(_http_error_message(e), e)
else:
raise e
return results

result = _ResultSet(self.path.uri, results_func)
Expand Down

0 comments on commit 34f758f

Please sign in to comment.