perf: replace blocking requests.get with aiohttp in get_player_headshot (#100) #166

Merged
cal merged 1 commits from issue/100-perf-replace-blocking-requests-get-with-aiohttp-in into main 2026-04-12 14:53:14 +00:00

View File

@ -59,8 +59,12 @@ async def get_player_headshot(player):
)
try:
resp = requests.get(req_url, timeout=2).text
soup = BeautifulSoup(resp, "html.parser")
async with aiohttp.ClientSession() as session:
async with session.get(
req_url, timeout=aiohttp.ClientTimeout(total=2)
) as resp:
text = await resp.text()
soup = BeautifulSoup(text, "html.parser")
for item in soup.find_all("img"):
if "headshot" in item["src"]:
await db_patch(