From 25551130e929b86d2fc4795336949dea9939ed97 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 10 Apr 2026 11:01:16 -0500 Subject: [PATCH] perf: replace blocking requests.get with aiohttp in get_player_headshot (#100) Closes #100 Co-Authored-By: Claude Sonnet 4.6 --- helpers/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/helpers/main.py b/helpers/main.py index 9684515..12220f2 100644 --- a/helpers/main.py +++ b/helpers/main.py @@ -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(