diff --git a/asyncio_pool/base_pool.py b/asyncio_pool/base_pool.py index 865bc70..35da35b 100644 --- a/asyncio_pool/base_pool.py +++ b/asyncio_pool/base_pool.py @@ -39,6 +39,9 @@ async def __aenter__(self): async def __aexit__(self, ext_type, exc, tb): await self.join() + def __len__(self): + return len(self._waiting) + self.n_active + @property def n_active(self): '''Counts active coroutines''' @@ -52,7 +55,7 @@ def is_empty(self): @property def is_full(self): '''Returns `True` if `size` coroutines are already active.''' - return self.size <= len(self._waiting) + self.n_active + return self.size <= len(self) async def join(self): '''Waits (blocks) for all spawned coroutines to finish, both active and