Skip to content

Commit ff92cfd

Browse files
committed
Use exponential backoff
1 parent 525d6eb commit ff92cfd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async def url_worker():
121121
continue
122122
if client_session is None:
123123
client_session = ClientSession()
124-
for _ in range(5): #" Up to 4 retries (5 attempts total)
124+
for retry_num in range(5): #" Up to 4 retries (5 attempts total)
125125
try:
126126
async with client_session.get("https://web.archive.org/save/" + next_job.url.url, allow_redirects=False) as resp:
127127
resp.raise_for_status()
@@ -134,7 +134,7 @@ async def url_worker():
134134
except Exception:
135135
print("Skipping exception during URL archiving:")
136136
print_exc()
137-
await asyncio.sleep(30)
137+
await asyncio.sleep(10 * pow(2, retry_num))
138138
else: # Ran out of retries, try again
139139
async with session.begin():
140140
if next_job.retry < 4:

0 commit comments

Comments
 (0)