Skip to content

Commit

Permalink
avoid consuming iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Sep 30, 2024
1 parent c7bc061 commit f7ea011
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/aiohappyeyeballs/_staggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ async def run_one_coro(
start_next_timer: Optional[asyncio.TimerHandle] = None
start_next: Optional[asyncio.Future[None]]
task: asyncio.Task[Optional[Tuple[_T, int]]]
waiters: Iterable[asyncio.Future[Any]]
done: Union[asyncio.Future[None], asyncio.Task[Optional[Tuple[_T, int]]]]
coro_iter = iter(coro_fns)
this_index = -1
Expand All @@ -149,16 +148,17 @@ async def run_one_coro(
break

while tasks:
waiters = [*tasks, start_next] if start_next else tasks
done = await _wait_one(waiters, loop)

if done is start_next:
# The current task has failed or the timer has expired
# so we need to start the next task.
if start_next_timer:
start_next_timer.cancel()
start_next_timer = None
break
if start_next:
done = await _wait_one([*tasks, start_next], loop)
if done is start_next:
# The current task has failed or the timer has expired
# so we need to start the next task.
if start_next_timer:
start_next_timer.cancel()
start_next_timer = None
break
else:
done = await _wait_one(tasks, loop)

if TYPE_CHECKING:
assert isinstance(done, asyncio.Task)
Expand Down

0 comments on commit f7ea011

Please sign in to comment.