Skip to content

Commit b3d791c

Browse files
SK-2293 max retry set to 3
1 parent adafc1c commit b3d791c

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

skyflow/vault/_client.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,12 @@ def insert(self, records: dict, options: InsertOptions = InsertOptions()):
5555
"Authorization": "Bearer " + self.storedToken,
5656
"sky-metadata": json.dumps(getMetrics())
5757
}
58-
max_retries = 1
58+
max_retries = 3
5959
# Use for-loop for retry logic, avoid code repetition
60-
for attempt in range(max_retries):
60+
for attempt in range(max_retries+1):
6161
try:
6262
# If jsonBody is a dict, use json=, else use data=
63-
if isinstance(jsonBody, dict):
64-
response = requests.post(requestURL, json=jsonBody, headers=headers)
65-
else:
66-
response = requests.post(requestURL, data=jsonBody, headers=headers)
63+
response = requests.post(requestURL, data=jsonBody, headers=headers)
6764
processedResponse = processResponse(response)
6865
result, partial = convertResponse(records, processedResponse, options)
6966
if partial:
@@ -75,16 +72,10 @@ def insert(self, records: dict, options: InsertOptions = InsertOptions()):
7572
log_info(InfoMessages.INSERT_DATA_SUCCESS.value, interface)
7673
return result
7774
except requests.exceptions.ConnectionError as err:
78-
log_error(f'Connection error inserting record: {err}', interface)
79-
if attempt == 0:
80-
log_info("Retrying record...", interface)
75+
if attempt < max_retries:
8176
continue
8277
else:
83-
raise SkyflowError(SkyflowErrorCodes.SERVER_ERROR, f"Connection error after retry: {err}", interface=interface)
84-
except Exception as err:
85-
log_error(f'Unexpected error in insert: {err}', interface)
86-
raise
87-
78+
raise SkyflowError(SkyflowErrorCodes.SERVER_ERROR, f"Error occurred: {err}", interface=interface)
8879

8980
def detokenize(self, records: dict, options: DetokenizeOptions = DetokenizeOptions()):
9081
interface = InterfaceName.DETOKENIZE.value

0 commit comments

Comments
 (0)