Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions aio_pika/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ async def __aexit__(

await asyncio.ensure_future(self.close())

def __len__(self) -> int:
return len(self.__item_set)


class PoolItemContextManager(Generic[T], AsyncContextManager):
__slots__ = "pool", "item"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async def create_instance():
return counter

pool = Pool(create_instance, max_size=max_size, loop=loop)
assert len(pool) == 0

async def getter():
nonlocal counter, pool
Expand All @@ -34,6 +35,8 @@ async def getter():

assert counter == max_size

assert len(pool) == max_size


class TestInstanceBase:
class Instance(PoolInstance):
Expand Down