Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def call(self, fn, *args, **kwargs):
start_time = int(round(workflow_time.time() * 1000))
attempt_number = 1
while True:
try:
val = yield fn(*args, **kwargs)
attempt = retrying.Attempt(val, attempt_number, False)
except Exception:
val = sys.exc_info()
attempt = retrying.Attempt(val, attempt_number, True)
if not self.should_reject(attempt):
return_(attempt.get(self._wrap_exception))
delay_since_first_attempt_ms = int(round(workflow_time.time() * 1000)) - start_time
if self.stop(attempt_number, delay_since_first_attempt_ms):
if not self._wrap_exception and attempt.has_exception:
# get() on an attempt with an exception should cause it to be raised, but raise just in case
raise attempt.get()
else:
raise RetryError(attempt)
else:
# use ceil since SWF timer resolution is in seconds
sleep = self.wait(attempt_number, delay_since_first_attempt_ms)
yield workflow_time.sleep(ceil(sleep / 1000.0))
def call(self, fn, *args, **kwargs):
start_time = int(round(workflow_time.time() * 1000))
attempt_number = 1
while True:
try:
val = yield fn(*args, **kwargs)
attempt = retrying.Attempt(val, attempt_number, False)
except Exception:
val = sys.exc_info()
attempt = retrying.Attempt(val, attempt_number, True)
if not self.should_reject(attempt):
return_(attempt.get(self._wrap_exception))
delay_since_first_attempt_ms = int(round(workflow_time.time() * 1000)) - start_time
if self.stop(attempt_number, delay_since_first_attempt_ms):
if not self._wrap_exception and attempt.has_exception:
# get() on an attempt with an exception should cause it to be raised, but raise just in case
raise attempt.get()
else:
raise RetryError(attempt)
else:
# use ceil since SWF timer resolution is in seconds