in darabonba/core.py [0:0]
def should_retry(options: RetryOptions, ctx: RetryPolicyContext) -> bool:
if ctx.retries_attempted == 0:
return True
if not options or not options.retryable:
return False
retries_attempted = ctx.retries_attempted
ex = ctx.exception
for condition in options.no_retry_condition:
if getattr(ex, 'name', None) in condition.exception or getattr(ex, 'code', None) in condition.error_code:
return False
for condition in options.retry_condition:
if getattr(ex, 'name', None) not in condition.exception and getattr(ex, 'code', None) not in condition.error_code:
continue
if retries_attempted >= condition.max_attempts:
return False
return True
return False