Skip to content

Commit 60c09d2

Browse files
committed
Further CRAI tasks cancellation improvement
1 parent 40e0179 commit 60c09d2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,12 @@ async def get_missing_energy_logs(self) -> None:
506506
result = await task
507507
# When an energy log collection task returns False, stop and cancel the remaining tasks
508508
if not result:
509-
for t in tasks[idx + 1 :]:
509+
to_cancel = tasks[idx + 1 :]
510+
for t in to_cancel:
510511
t.cancel()
512+
# Drain cancellations to avoid "Task exception was never retrieved"
513+
from asyncio import gather as _gather
514+
await _gather(*to_cancel, return_exceptions=True)
511515
break
512516

513517
if self._cache_enabled:

0 commit comments

Comments
 (0)