Skip to content

Commit

Permalink
fix: check done
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Apr 26, 2024
1 parent 3436040 commit 4293dda
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion a_sync/_smart.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def __await__(self: "SmartFuture"):
return self.result() # May raise too.
@property
def num_waiters(self: "SmartFuture") -> int:
return sum(getattr(waiter, 'num_waiters', 0) + 1 for waiter in self._waiters)
# NOTE: we check .done() because the callback may not have ran yet and its very lightweight
return sum(getattr(waiter, 'num_waiters', 0) + 1 for waiter in self._waiters if not waiter.done())
def _waiter_done_callback(self, waiter: "_SmartFutureMixin") -> None:
"Removes the waiter from _waiters, and _queue._futs if applicable"
self._waiters.remove(waiter)
Expand Down

0 comments on commit 4293dda

Please sign in to comment.