From 6866cca929b733a35b4884e4ce156a2e88565093 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Sat, 7 May 2022 22:08:20 +0200 Subject: [PATCH] Add timeout (#71499) --- homeassistant/components/brother/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/brother/__init__.py b/homeassistant/components/brother/__init__.py index ce715e991b0..96e2ad069ce 100644 --- a/homeassistant/components/brother/__init__.py +++ b/homeassistant/components/brother/__init__.py @@ -4,6 +4,7 @@ from __future__ import annotations from datetime import timedelta import logging +import async_timeout from brother import Brother, DictToObj, SnmpError, UnsupportedModel import pysnmp.hlapi.asyncio as SnmpEngine @@ -76,7 +77,8 @@ class BrotherDataUpdateCoordinator(DataUpdateCoordinator): async def _async_update_data(self) -> DictToObj: """Update data via library.""" try: - data = await self.brother.async_update() + async with async_timeout.timeout(20): + data = await self.brother.async_update() except (ConnectionError, SnmpError, UnsupportedModel) as error: raise UpdateFailed(error) from error return data