Skip to content

Commit

Permalink
fix: num_waiters
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Apr 24, 2024
1 parent 54e2e47 commit d52bbde
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 @@ -16,6 +16,7 @@

class _SmartFutureMixin(Generic[T]):
_queue: Optional["SmartProcessingQueue[Any, Any, T]"] = None
_waiters: Set["asyncio.Task[T]"]
def __await__(self):
logger.debug("entering %s", self)
if self.done():
Expand All @@ -32,7 +33,7 @@ def __await__(self):
return self.result() # May raise too.
@property
def num_waiters(self) -> int:
return sum(getattr(waiter, 'num_waiters', 1) for waiter in self._waiters)
return sum(getattr(waiter, 'num_waiters', 0) + 1 for waiter in self._waiters)

class SmartFuture(_SmartFutureMixin[T], asyncio.Future):
def __init__(self, queue: "SmartProcessingQueue[Any, Any, T]", key: _Key, *, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
Expand Down

0 comments on commit d52bbde

Please sign in to comment.