Skip to content

Commit

Permalink
add exponential backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemiyGranat committed Jan 27, 2024
1 parent 0346df2 commit 5cc27dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ rye shell
rye sync
rye run uvicorn --app-dir=backend/src main:app
```

## TODO
* [ ] Distributed scraping
* [ ] ...
4 changes: 2 additions & 2 deletions scraper/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from imagehash import phash
from PIL import Image
from pydantic import BaseModel
from tenacity import retry, stop_after_attempt
from tenacity import retry, stop_after_attempt, wait_exponential

import shared.entities as entities

Expand All @@ -18,7 +18,7 @@ class ScraperInfo(BaseModel):
images_scraped: int


@retry(stop=stop_after_attempt(7))
@retry(stop=stop_after_attempt(7), wait=wait_exponential(multiplier=1, max=60))
async def get_with_retry(url: str):
return await ctx.http_client.get(url)

Expand Down

0 comments on commit 5cc27dd

Please sign in to comment.