From 11a4ed05a69e4acaa51385348bdaa0bba7412ede Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Fri, 26 Nov 2021 10:51:30 -0800 Subject: [PATCH] Wait between weblate API requests to avoid hammering the server --- docs/check-weblate.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/check-weblate.py b/docs/check-weblate.py index a5dc4dc8..76cc6942 100755 --- a/docs/check-weblate.py +++ b/docs/check-weblate.py @@ -13,6 +13,10 @@ docs_translations = {} async def api(path): url = f"https://hosted.weblate.org{path}" + # Wait a bit before each API call, to avoid hammering the server and + # getting temporarily blocked + await asyncio.sleep(1) + async with httpx.AsyncClient() as client: r = await client.get( url, headers={"Authorization": f"Token {api_token}"}, timeout=60