Rest API - Webhooks and Events
You want to implement retry logic that tries up to 4 times with increasing wait times: 1s, 2s, 4s, then stops. Which code snippet correctly implements this?
Option A:
for i in range(3):
response = call_api()
if response.ok:
break
time.sleep(2 ** i)
Option B:
for i in range(1, 5):
response = call_api()
if response.ok:
break
time.sleep(i)
Option C:
for i in range(4):
response = call_api()
if response.ok:
break
time.sleep(i)
Option D:
for i in range(4):
response = call_api()
if response.ok:
break
time.sleep(2 * i)