summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandy <andy@whiskeymedia.com>2011-07-16 16:25:56 -0700
committerandy <andy@whiskeymedia.com>2011-07-16 16:25:56 -0700
commitc9daf07bb67696263118a17b0359fafa7ac27c53 (patch)
treea4eb55d55b492ba702cca89b150b0b6d8cfea68f
parent0697b79b91196a826d05e346b3436fe7ff2cf929 (diff)
downloadredis-py-c9daf07bb67696263118a17b0359fafa7ac27c53.tar.gz
Fix for #161. Make sure we release the connection back to the pool after
execute is called in a pipeline.
-rw-r--r--CHANGES3
-rw-r--r--redis/client.py10
2 files changed, 11 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index a4e5617..829fb90 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+* 2.4.7 (in developmen)
+ * Fixed a bug where some connections we're getting released back to the
+ connection pool during pipelines.
* 2.4.6
* Variadic arguments for SADD, SREM, ZREN, HDEL, LPUSH, and RPUSH. Thanks
Raphaƫl Vinot.
diff --git a/redis/client.py b/redis/client.py
index 039024d..10e5060 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -1334,8 +1334,14 @@ class Pipeline(Redis):
execute = self._execute_transaction
else:
execute = self._execute_pipeline
- conn = self.connection or \
- self.connection_pool.get_connection('MULTI', self.shard_hint)
+
+ conn = self.connection
+ if not conn:
+ conn = self.connection_pool.get_connection('MULTI', self.shard_hint)
+ # assign to self.connection so reset() releases the connection
+ # back to the pool after we're done
+ self.connection = conn
+
try:
return execute(conn, stack)
except ConnectionError: