@@ -191,19 +191,6 @@ def __init__(self, host='localhost', port=6379,
191
191
encoding_errors = errors
192
192
)
193
193
194
- #### Legacy accessors of connection information ####
195
- def _get_host (self ):
196
- return self .connection .host
197
- host = property (_get_host )
198
-
199
- def _get_port (self ):
200
- return self .connection .port
201
- port = property (_get_port )
202
-
203
- def _get_db (self ):
204
- return self .connection .db
205
- db = property (_get_db )
206
-
207
194
def pipeline (self , transaction = True ):
208
195
"""
209
196
Return a new pipeline object that can queue multiple commands for
@@ -230,9 +217,9 @@ def lock(self, name, timeout=None, sleep=0.1):
230
217
231
218
#### COMMAND EXECUTION AND PROTOCOL PARSING ####
232
219
def execute_command (self , * args , ** options ):
233
- connection = self .connection_pool .get_connection ()
220
+ command_name = args [0 ]
221
+ connection = self .connection_pool .get_connection (command_name )
234
222
try :
235
- command_name = args [0 ]
236
223
subscription_command = command_name in self .SUBSCRIPTION_COMMANDS
237
224
if self .subscribed and not subscription_command :
238
225
raise PubSubError ("Cannot issue commands other than SUBSCRIBE "
@@ -1121,6 +1108,9 @@ def hvals(self, name):
1121
1108
"Return the list of values within hash ``name``"
1122
1109
return self .execute_command ('HVALS' , name )
1123
1110
1111
+ def pubsub (self ):
1112
+ return PubSub (self .connection_pool )
1113
+
1124
1114
1125
1115
# channels
1126
1116
def psubscribe (self , patterns ):
@@ -1236,7 +1226,7 @@ def execute_command(self, *args, **options):
1236
1226
return self
1237
1227
1238
1228
def _execute_transaction (self , commands ):
1239
- connection = self .connection_pool .get_connection ()
1229
+ connection = self .connection_pool .get_connection ('MULTI' )
1240
1230
try :
1241
1231
all_cmds = '' .join (starmap (connection .pack_command ,
1242
1232
[args for args , options in commands ]))
@@ -1272,7 +1262,7 @@ def _execute_transaction(self, commands):
1272
1262
1273
1263
def _execute_pipeline (self , commands ):
1274
1264
# build up all commands into a single request to increase network perf
1275
- connection = self .connection_pool .get_connection ()
1265
+ connection = self .connection_pool .get_connection ('MULTI' )
1276
1266
try :
1277
1267
all_cmds = '' .join (starmap (connection .pack_command ,
1278
1268
[args for args , options in commands ]))
0 commit comments