reduce concurrency when fetching images + add retries
This commit is contained in:
parent
59c33428c2
commit
20ff91d663
3 changed files with 8 additions and 7 deletions
|
|
@ -3,13 +3,13 @@ import json
|
|||
from pathlib import Path
|
||||
import aiohttp
|
||||
from repositories import ListingRepository
|
||||
from tenacity import retry, wait_random
|
||||
from tenacity import retry, stop_after_attempt, wait_random
|
||||
from tqdm.asyncio import tqdm
|
||||
|
||||
from models import Listing
|
||||
|
||||
# Setting this too high either crashes rightmove or gets us blocked
|
||||
semaphore = asyncio.Semaphore(10)
|
||||
semaphore = asyncio.Semaphore(5)
|
||||
|
||||
|
||||
async def dump_images(
|
||||
|
|
@ -25,7 +25,7 @@ async def dump_images(
|
|||
)
|
||||
|
||||
|
||||
@retry(wait=wait_random(min=1, max=2))
|
||||
@retry(wait=wait_random(min=1, max=2), stop=stop_after_attempt(3))
|
||||
async def dump_images_for_listing(listing: Listing, base_path: Path) -> Listing | None:
|
||||
all_floorplans = listing.additional_info["property"]["floorplans"]
|
||||
for floorplan in all_floorplans:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue