Skip to content

Commit

Permalink
More tweaking + BUILD
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Nov 16, 2024
1 parent 04ed64a commit 6f6cf5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion indexer/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ async def thread(id: int) -> dict[str, str] | None:
cookies=f95zone.cookies,
) as req:
if req.status == 429 and retries > 1:
await asyncio.sleep(0.5)
logger.warning("Hit a ratelimit, sleeping 2 seconds")
await asyncio.sleep(2)
retries -= 1;
continue
res = await req.read()
Expand Down
6 changes: 4 additions & 2 deletions modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
updating = False
session: aiohttp.ClientSession = None
webpage_prefix = "F95Checker-Temp-"
xenforo_ratelimit = aiolimiter.AsyncLimiter(max_rate=1, time_period=1)
xenforo_ratelimit = aiolimiter.AsyncLimiter(max_rate=1, time_period=2)
fast_checks_sem: asyncio.Semaphore = None
full_checks_sem: asyncio.Semaphore = None
fast_checks_counter = 0
Expand Down Expand Up @@ -117,6 +117,8 @@ async def request(method: str, url: str, read=True, no_cookies=False, **kwargs):
ddos_guard_cookies = {}
ddos_guard_first_challenge = False
is_xenforo_request = url.startswith(f95_host)
if is_xenforo_request:
retries += 5
while retries:
try:
# Only ratelimit when connecting to F95zone
Expand All @@ -129,7 +131,7 @@ async def request(method: str, url: str, read=True, no_cookies=False, **kwargs):
**kwargs
) as req:
if is_xenforo_request and req.status == 429 and retries > 1:
await asyncio.sleep(1)
await asyncio.sleep(2)
retries -= 1
continue
if not read:
Expand Down

0 comments on commit 6f6cf5f

Please sign in to comment.