Skip to content

Commit

Permalink
fix: task exception never retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Apr 26, 2024
1 parent 2b5a3b2 commit ed4f398
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions a_sync/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,14 @@ async def __aiter__(self, pop: bool = False) -> AsyncIterator[Tuple[K, V]]:
if self._init_loader:
while not self._init_loader.done():
# NOTE if `_init_loader` has an exception it will return first, otherwise `_init_loader_next` will return always
await asyncio.wait(
[self._init_loader_next(), self._init_loader],
done: Set[asyncio.Task]
done, pending = await asyncio.wait(
[create_task(self._init_loader_next(), log_destroy_pending=False), self._init_loader],
return_when=asyncio.FIRST_COMPLETED
)
for task in done:
# check for exceptions
await task
while unyielded := [key for key in self if key not in yielded]:
if ready := {key: task for key in unyielded if (task:=self[key]).done()}:
for key, task in ready.items():
Expand Down

0 comments on commit ed4f398

Please sign in to comment.