Skip to content

Commit e4f3db6

Browse files
committed
refactor: Add commands for setting client name, library info, database selection, and client caching
1 parent 3040b74 commit e4f3db6

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

redis/connection.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -395,29 +395,16 @@ def on_connect(self):
395395
# if a client_name is given, set it
396396
if self.client_name:
397397
self.send_command("CLIENT", "SETNAME", self.client_name)
398-
if str_if_bytes(self.read_response()) != "OK":
399-
raise ConnectionError("Error setting client name")
400398

401-
try:
402-
# set the library name and version
403-
if self.lib_name:
404-
self.send_command("CLIENT", "SETINFO", "LIB-NAME", self.lib_name)
405-
self.read_response()
406-
except ResponseError:
407-
pass
408-
409-
try:
410-
if self.lib_version:
411-
self.send_command("CLIENT", "SETINFO", "LIB-VER", self.lib_version)
412-
self.read_response()
413-
except ResponseError:
414-
pass
399+
# set the library name and version
400+
if self.lib_name:
401+
self.send_command("CLIENT", "SETINFO", "LIB-NAME", self.lib_name)
402+
if self.lib_version:
403+
self.send_command("CLIENT", "SETINFO", "LIB-VER", self.lib_version)
415404

416405
# if a database is specified, switch to it
417406
if self.db:
418407
self.send_command("SELECT", self.db)
419-
if str_if_bytes(self.read_response()) != "OK":
420-
raise ConnectionError("Invalid Database")
421408

422409
# if client caching is enabled, start tracking
423410
if self.client_cache:

0 commit comments

Comments
 (0)