From af42881339e3bd15eb1de757cfba56d0de07815d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 23 Jul 2024 08:19:46 +0200 Subject: [PATCH] interface: switch to asyncio TaskGroup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- aemet_opendata/interface.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/aemet_opendata/interface.py b/aemet_opendata/interface.py index 4ec2e16..fe0d89f 100644 --- a/aemet_opendata/interface.py +++ b/aemet_opendata/interface.py @@ -417,12 +417,10 @@ async def update_station(self) -> None: async def update(self) -> None: """Update all AEMET OpenData data.""" - tasks = [ - self.update_daily(), - self.update_hourly(), - self.update_station(), - ] - await asyncio.gather(*tasks) + async with asyncio.TaskGroup() as tg: + tg.create_task(self.update_daily()) + tg.create_task(self.update_hourly()) + tg.create_task(self.update_station()) def weather(self) -> dict[str, Any] | None: """Update AEMET OpenData town daily forecast."""