Skip to content

Commit b0cc6b9

Browse files
committed
ConnectionPool's get_connection() now can take optional kwargs
1 parent e2b6a80 commit b0cc6b9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

redis/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ def pubsub(self, shard_hint=None):
216216
#### COMMAND EXECUTION AND PROTOCOL PARSING ####
217217
def execute_command(self, *args, **options):
218218
"Execute a command and return a parsed response"
219+
pool = self.connection_pool
219220
command_name = args[0]
220-
connection = self.connection_pool.get_connection(command_name)
221+
connection = pool.get_connection(command_name, **options)
221222
try:
222223
connection.send_command(*args)
223224
return self.parse_response(connection, command_name, **options)
@@ -226,7 +227,7 @@ def execute_command(self, *args, **options):
226227
connection.send_command(*args)
227228
return self.parse_response(connection, command_name, **options)
228229
finally:
229-
self.connection_pool.release(connection)
230+
pool.release(connection)
230231

231232
def parse_response(self, connection, command_name, **options):
232233
"Parses a response from the Redis server"

redis/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def __init__(self, connection_class=Connection, max_connections=None,
250250
self._available_connections = []
251251
self._in_use_connections = set()
252252

253-
def get_connection(self, command_name, *keys):
253+
def get_connection(self, command_name, *keys, **options):
254254
"Get a connection from the pool"
255255
try:
256256
connection = self._available_connections.pop()

0 commit comments

Comments
 (0)