Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Stop rate limit from causing backfill to fail #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions mauigpapi/http/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
ThreadItemType,
)
from .base import BaseAndroidAPI, T
from ..errors import IGRateLimitError
from asyncio import sleep


class ThreadAPI(BaseAndroidAPI):
Expand Down Expand Up @@ -90,9 +92,13 @@ async def get_thread(
"seq_id": seq_id,
"limit": limit,
}
return await self.std_http_get(
f"/api/v1/direct_v2/threads/{thread_id}/", query=query, response_type=DMThreadResponse
)
for _ in range(15):
try:
return await self.std_http_get(
f"/api/v1/direct_v2/threads/{thread_id}/", query=query, response_type=DMThreadResponse
)
except IGRateLimitError as e:
await sleep(300)

async def iter_thread(
self, thread_id: str, seq_id: int | None = None, cursor: str | None = None
Expand Down