perf: replace blocking requests.get with aiohttp in get_player_headshot (#100)
All checks were successful
Ruff Lint / lint (pull_request) Successful in 16s

Closes #100

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-04-10 11:01:16 -05:00
parent 2ce6bbe57a
commit d957bbe7ab

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(