Skip to content

Commit

Permalink
Merge branch 'dockerize'
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Mar 11, 2016
2 parents b7f2ffe + 302c531 commit b3146a9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGES
=======

0.3 (12-15-2016)
----------------

- Dockerize tests

- Reuse memcached connections in Client Pool #4

0.2 (12-15-2015)
----------------

Expand Down
2 changes: 2 additions & 0 deletions aiomcache/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def stats(self, conn, args=None):
result[terms[1]] = None
elif len(terms) == 3 and terms[0] == b'STAT':
result[terms[1]] = terms[2]
elif len(terms) >= 3 and terms[0] == b'STAT':
result[terms[1]] = b' '.join(terms[2:])
else:
raise ClientException('stats failed', resp)

Expand Down
2 changes: 2 additions & 0 deletions aiomcache/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def acquire(self):
if _conn.reader.at_eof() or _conn.reader.exception():
self._do_close(_conn)
conn = None
else:
conn = _conn

if conn is None:
conn = yield from self._create_new_conn()
Expand Down
16 changes: 16 additions & 0 deletions tests/pool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,19 @@ def test_pool_is_full(mcache_params, loop):
assert pool.size() == 3
pool.release(conn)
assert pool.size() == 2


@pytest.mark.run_loop
def test_acquire_dont_create_new_connection_if_have_conn_in_pool(mcache_params,
loop):
pool = MemcachePool(minsize=1, maxsize=5, loop=loop, **mcache_params)
assert pool.size() == 0

# Add a valid connection
_conn = yield from pool._create_new_conn()
yield from pool._pool.put(_conn)
assert pool.size() == 1

conn = yield from pool.acquire()
assert conn is _conn
assert pool.size() == 1

0 comments on commit b3146a9

Please sign in to comment.