@@ -352,18 +352,17 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
352
352
return False , "200 codes are not retried"
353
353
354
354
if status_code == 401 :
355
- raise NonRecoverableNetworkError (
356
- "Received 401 - UNAUTHORIZED. Confirm your authentication credentials."
355
+ return (
356
+ False ,
357
+ "Received 401 - UNAUTHORIZED. Confirm your authentication credentials." ,
357
358
)
358
359
359
360
if status_code == 403 :
360
- raise NonRecoverableNetworkError (
361
- "Received 403 - FORBIDDEN. Confirm your authentication credentials."
362
- )
361
+ return False , "403 codes are not retried"
363
362
364
363
# Request failed and server said NotImplemented. This isn't recoverable. Don't retry.
365
364
if status_code == 501 :
366
- raise NonRecoverableNetworkError ( "Received code 501 from server." )
365
+ return False , "Received code 501 from server."
367
366
368
367
# Request failed and this method is not retryable. We only retry POST requests.
369
368
if not self ._is_method_retryable (method ):
@@ -382,8 +381,9 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
382
381
and self .command_type == CommandType .CLOSE_SESSION
383
382
and len (self .history ) > 0
384
383
):
385
- raise SessionAlreadyClosedError (
386
- "CloseSession received 404 code from Databricks. Session is already closed."
384
+ return (
385
+ False ,
386
+ "CloseSession received 404 code from Databricks. Session is already closed." ,
387
387
)
388
388
389
389
# Request failed with 404 because CloseOperation returns 404 if you repeat the request.
@@ -392,8 +392,9 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
392
392
and self .command_type == CommandType .CLOSE_OPERATION
393
393
and len (self .history ) > 0
394
394
):
395
- raise CursorAlreadyClosedError (
396
- "CloseOperation received 404 code from Databricks. Cursor is already closed."
395
+ return (
396
+ False ,
397
+ "CloseOperation received 404 code from Databricks. Cursor is already closed." ,
397
398
)
398
399
399
400
# Request failed, was an ExecuteStatement and the command may have reached the server
@@ -402,8 +403,9 @@ def should_retry(self, method: str, status_code: int) -> Tuple[bool, str]:
402
403
and status_code not in self .status_forcelist
403
404
and status_code not in self .force_dangerous_codes
404
405
):
405
- raise UnsafeToRetryError (
406
- "ExecuteStatement command can only be retried for codes 429 and 503"
406
+ return (
407
+ False ,
408
+ "ExecuteStatement command can only be retried for codes 429 and 503" ,
407
409
)
408
410
409
411
# Request failed with a dangerous code, was an ExecuteStatement, but user forced retries for this
0 commit comments