Skip to content

Commit

Permalink
Lazy load redis asyncio.Lock (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoucheiron authored and argaen committed Apr 26, 2018
1 parent baf50df commit f97f90f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion aiocache/backends/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ def __init__(
self.pool_min_size = pool_min_size
self.pool_max_size = pool_max_size
self.create_connection_timeout = create_connection_timeout
self._pool_lock = asyncio.Lock()
self.__pool_lock = None
self._loop = loop
self._pool = None

@property
def _pool_lock(self):
if self.__pool_lock is None:
self.__pool_lock = asyncio.Lock()
return self.__pool_lock

async def acquire_conn(self):
await self._get_pool()
conn = await self._pool.acquire()
Expand Down

0 comments on commit f97f90f

Please sign in to comment.