Skip to content

Commit f5a7a56

Browse files
committed
2nd try fixing missing await task
1 parent 24c0136 commit f5a7a56

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from asyncio import Task, create_task
5+
from asyncio import Task, create_task, gather
66
from collections.abc import Awaitable, Callable
77
from dataclasses import replace
88
from datetime import UTC, datetime
@@ -440,6 +440,7 @@ async def get_missing_energy_logs(self) -> None:
440440
self._energy_counters.update()
441441
if self._current_log_address is None:
442442
return None
443+
443444
if self._energy_counters.log_addresses_missing is None:
444445
_LOGGER.debug(
445446
"Start with initial energy request for the last 10 log addresses for node %s.",
@@ -449,17 +450,17 @@ async def get_missing_energy_logs(self) -> None:
449450
log_address = self._current_log_address
450451
log_update_tasks = []
451452
while total_addresses > 0:
452-
result = await self.energy_log_update(log_address)
453-
log_update_tasks.append(result)
453+
log_update_tasks.append(self.energy_log_update(log_address))
454454
log_address, _ = calc_log_address(log_address, 1, -4)
455455
total_addresses -= 1
456456

457-
for task in log_update_tasks:
458-
await task
457+
await gather(*log_update_tasks)
459458

460459
if self._cache_enabled:
461460
await self._energy_log_records_save_to_cache()
461+
462462
return
463+
463464
if self._energy_counters.log_addresses_missing is not None:
464465
_LOGGER.debug("Task created to get missing logs of %s", self._mac_in_str)
465466
if (

0 commit comments

Comments
 (0)