Skip to content

Instantly share code, notes, and snippets.

@1st1
Created October 7, 2015 20:19
Show Gist options
  • Select an option

  • Save 1st1/1f7eff22b04593f03cc8 to your computer and use it in GitHub Desktop.

Select an option

Save 1st1/1f7eff22b04593f03cc8 to your computer and use it in GitHub Desktop.
class _RedisPool(aioredis.RedisPool):
@asyncio.coroutine
def acquire(self):
# XXX
with (yield from self._cond):
while True:
yield from self._fill_free(override_min=True)
if self.freesize:
conn = self._pool.popleft()
if conn.closed:
continue
assert conn not in self._used, (conn, self._used)
self._used.add(conn)
return conn
else:
yield from self._cond.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment