Skip to content

Commit

Permalink
interface: switch to asyncio TaskGroup
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
  • Loading branch information
Noltari authored Jul 23, 2024
1 parent d7510d4 commit af42881
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions aemet_opendata/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit af42881

Please sign in to comment.