Skip to content

Commit 612d0ed

Browse files
authored
Add connection timeout to API requests (#238)
1 parent 5cc84c2 commit 612d0ed

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

switchbot/devices/lock.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ async def api_request(
9292
headers: dict = None,
9393
) -> dict:
9494
url = f"https://{subdomain}.{SWITCHBOT_APP_API_BASE_URL}/{path}"
95-
async with session.post(url, json=data, headers=headers) as result:
95+
async with session.post(
96+
url,
97+
json=data,
98+
headers=headers,
99+
timeout=aiohttp.ClientTimeout(total=10),
100+
) as result:
96101
if result.status > 299:
97102
raise SwitchbotApiError(
98103
f"Unexpected status code returned by SwitchBot API: {result.status}"

0 commit comments

Comments
 (0)