Skip to content

Commit

Permalink
Add connection timeout to API requests (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsypniewski authored May 24, 2024
1 parent 5cc84c2 commit 612d0ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion switchbot/devices/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ async def api_request(
headers: dict = None,
) -> dict:
url = f"https://{subdomain}.{SWITCHBOT_APP_API_BASE_URL}/{path}"
async with session.post(url, json=data, headers=headers) as result:
async with session.post(
url,
json=data,
headers=headers,
timeout=aiohttp.ClientTimeout(total=10),
) as result:
if result.status > 299:
raise SwitchbotApiError(
f"Unexpected status code returned by SwitchBot API: {result.status}"
Expand Down

0 comments on commit 612d0ed

Please sign in to comment.