Skip to content

Commit d878358

Browse files
authored
Merge pull request #132 from varenc/tokencost-fetch-timeout
Set 10-second timeout when requesting model prices
2 parents 43fdd5e + ffe46e6 commit d878358

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tokencost/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ async def fetch_costs():
3434
Raises:
3535
Exception: If the request fails.
3636
"""
37-
async with aiohttp.ClientSession(trust_env=True) as session:
37+
timeout = aiohttp.ClientTimeout(total=10) # 10 seconds timeout
38+
async with aiohttp.ClientSession(trust_env=True, timeout=timeout) as session:
3839
async with session.get(PRICES_URL) as response:
3940
if response.status == 200:
4041
return await response.json(content_type=None)

0 commit comments

Comments
 (0)