Skip to content

Commit a5ad044

Browse files
committed
🐛 fix: reduce concurrency due to strict rate limiter
1 parent 092b3ee commit a5ad044

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

app/crawler/contest_record_and_submission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def request_contest_records(
4242
]
4343
responses = await multi_http_request(
4444
{url: {"url": url, "method": "GET"} for url in url_list},
45-
concurrent_num=20 if data_region == "US" else 50,
45+
concurrent_num=5 if data_region == "US" else 10,
4646
)
4747
for res in responses:
4848
if res is None:

app/handler/user.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ async def update_all_users_in_database(
104104
await gather_with_limited_concurrency(
105105
[
106106
# CN site has a strong rate limit
107-
gather_with_limited_concurrency(cn_tasks, 4),
108-
gather_with_limited_concurrency(us_tasks, 25),
107+
gather_with_limited_concurrency(cn_tasks, 1),
108+
gather_with_limited_concurrency(us_tasks, 5),
109109
],
110110
30,
111111
)
@@ -163,6 +163,7 @@ async def save_users_of_contest(
163163
]
164164
cursor = col.aggregate(pipeline)
165165
docs = await cursor.to_list(length=None)
166+
logger.info(f"docs length = {len(docs)}")
166167
cn_tasks = []
167168
us_tasks = []
168169
for doc in docs:
@@ -181,8 +182,8 @@ async def save_users_of_contest(
181182
await gather_with_limited_concurrency(
182183
[
183184
# CN site has a strong rate limit
184-
gather_with_limited_concurrency(cn_tasks, 4),
185-
gather_with_limited_concurrency(us_tasks, 25),
186-
30,
185+
gather_with_limited_concurrency(cn_tasks, 1),
186+
gather_with_limited_concurrency(us_tasks, 5),
187187
],
188+
30,
188189
)

0 commit comments

Comments
 (0)