@@ -379,14 +379,6 @@ def on_connect(self):
379
379
raise ConnectionError ("Invalid RESP version" )
380
380
# fall back to AUTH command (for Redis versions less than 6.0)
381
381
else :
382
- self .send_command ('MULTI' )
383
- self .read_response ()
384
-
385
- # avoid checking health here -- PING will fail if we try
386
- # to check the health prior to the AUTH
387
- if auth_args :
388
- self .send_command ("AUTH" , * auth_args , check_health = False )
389
- auth_command_response = True
390
382
# avoid checking health here -- PING will fail if we try
391
383
# to check the health prior to the AUTH
392
384
if auth_args :
@@ -396,24 +388,28 @@ def on_connect(self):
396
388
else :
397
389
self .send_command ("AUTH" , * auth_args , check_health = False )
398
390
391
+ # start a transaction block with MULTI
392
+ try :
393
+ self .send_command ('MULTI' )
394
+ self .read_response ()
399
395
400
- # if a client_name is given, set it
401
- if self .client_name :
402
- self .send_command ("CLIENT" , "SETNAME" , self .client_name )
396
+ # if a client_name is given, set it
397
+ if self .client_name :
398
+ self .send_command ("CLIENT" , "SETNAME" , self .client_name )
403
399
404
- # set the library name and version
405
- if self .lib_name :
406
- self .send_command ("CLIENT" , "SETINFO" , "LIB-NAME" , self .lib_name )
407
- if self .lib_version :
408
- self .send_command ("CLIENT" , "SETINFO" , "LIB-VER" , self .lib_version )
400
+ # set the library name and version
401
+ if self .lib_name :
402
+ self .send_command ("CLIENT" , "SETINFO" , "LIB-NAME" , self .lib_name )
403
+ if self .lib_version :
404
+ self .send_command ("CLIENT" , "SETINFO" , "LIB-VER" , self .lib_version )
409
405
410
- # if a database is specified, switch to it
411
- if self .db :
412
- self .send_command ("SELECT" , self .db )
406
+ # if a database is specified, switch to it
407
+ if self .db :
408
+ self .send_command ("SELECT" , self .db )
413
409
414
- # if client caching is enabled, start tracking
415
- if self .client_cache :
416
- self .send_command ("CLIENT" , "TRACKING" , "ON" )
410
+ # if client caching is enabled, start tracking
411
+ if self .client_cache :
412
+ self .send_command ("CLIENT" , "TRACKING" , "ON" )
417
413
418
414
# execute the MULTI block
419
415
try :
0 commit comments