Skip to content

Commit

Permalink
add more type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
p7g committed May 29, 2024
1 parent 11ead32 commit fb76d00
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions asyncio_connection_pool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
strategy: ConnectionStrategy[Conn],
max_size: int,
burst_limit: Optional[int] = None
):
) -> None:
self._loop = asyncio.get_event_loop()
self.strategy = strategy
self.max_size = max_size
Expand All @@ -82,20 +82,20 @@ def _waiters(self) -> int:
waiters = self.available._getters # type: ignore
return sum(not (w.done() or w.cancelled()) for w in waiters)

async def _connection_maker(self):
async def _connection_maker(self) -> Conn:
try:
conn = await self.strategy.make_connection()
finally:
self.currently_allocating -= 1
self.in_use += 1
return conn

async def _connection_waiter(self):
async def _connection_waiter(self) -> Conn:
conn = await self.available.get()
self.in_use += 1
return conn

def _get_conn(self) -> "Awaitable[Conn]":
def _get_conn(self) -> Awaitable[Conn]:
# This function is how we avoid explicitly locking. Since it is
# synchronous, we do all the "book-keeping" required to get a
# connection synchronously, and return a Future or Task which can be
Expand Down

0 comments on commit fb76d00

Please sign in to comment.