Wait between weblate API requests to avoid hammering the server

This commit is contained in:
Micah Lee 2021-11-26 10:51:30 -08:00
parent 2a67f9a78f
commit 11a4ed05a6
No known key found for this signature in database
GPG key ID: 403C2657CD994F73

View file

@ -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