add tenacity to retry transient blockouts by rightmove

This commit is contained in:
Viktor Barzin 2025-06-08 20:59:04 +00:00
parent 289206afc0
commit 9b2653ce91
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863
3 changed files with 20 additions and 3 deletions

18
crawler/poetry.lock generated
View file

@ -3748,6 +3748,22 @@ pure-eval = "*"
[package.extras]
tests = ["cython", "littleutils", "pygments", "pytest", "typeguard"]
[[package]]
name = "tenacity"
version = "9.1.2"
description = "Retry code until it succeeds"
optional = false
python-versions = ">=3.9"
groups = ["main"]
files = [
{file = "tenacity-9.1.2-py3-none-any.whl", hash = "sha256:f77bf36710d8b73a50b2dd155c97b870017ad21afe6ab300326b0371b3b05138"},
{file = "tenacity-9.1.2.tar.gz", hash = "sha256:1169d376c297e7de388d18b4481760d478b0e99a777cad3a9c86e556f4b697cb"},
]
[package.extras]
doc = ["reno", "sphinx"]
test = ["pytest", "tornado (>=4.5)", "typeguard"]
[[package]]
name = "terminado"
version = "0.18.1"
@ -4211,4 +4227,4 @@ propcache = ">=0.2.1"
[metadata]
lock-version = "2.1"
python-versions = ">3.11"
content-hash = "75939eb35cc0f4f8092c32114eede93ad0ddc56aab3bb1ee367b69ad89031ad9"
content-hash = "5e7d837fbd1e473139e34d2981ff32f9dad9bb5f9e1ac8287f3523327e4253bd"

View file

@ -24,6 +24,7 @@ aiohttp = "^3.11.18"
sqlmodel = "^0.0.24"
alembic = "^1.16.1"
sqlalchemy = {extras = ["asyncio"], version = "^2.0.41"}
tenacity = "^9.1.2"
[tool.poetry.group.dev.dependencies]
ipdb = "^0.13.13"

View file

@ -1,12 +1,11 @@
# from diskcache import Cache
import asyncio
from dataclasses import dataclass
from datetime import datetime
import enum
from typing import Any
import aiohttp
from data_access import Listing
from models.listing import FurnishType, ListingType, QueryParameters
from tenacity import retry, wait_random
headers = {
@ -27,6 +26,7 @@ class PropertyType(enum.StrEnum):
TERRACED = "terraced"
@retry(wait=wait_random(min=1, max=2))
async def detail_query(detail_id: int) -> dict[str, Any]:
params = {
"apiApplication": "ANDROID",