def retry_with_task(a, b, task=None): assert task is not None if a + b < 0: raise RetryTask() return a + b
def task_a(n): state[0] = state[0] + n if state[0] < 2: raise RetryTask('asdf') return state[0]
def explicit_retry(k): if k not in state: state[k] = 'fixed' raise RetryTask() return state[k]
def retry_once(): if not retry_once._did_retry: retry_once._did_retry = True raise RetryTask() return "Done."