Merge pull request 'perf: replace blocking requests.get with aiohttp in get_player_headshot (#100)' (#166) from issue/100-perf-replace-blocking-requests-get-with-aiohttp-in into main
Reviewed-on: #166 Reviewed-by: Claude Reviewer <cal.corum+claude-reviewer@gmail.com>
This commit is contained in:
commit
61d61b9348
@ -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(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user