Repository: redis/redis-py

Issue:
Client name doesn't persist after lost connection when set using client_setname
**Version**: redis-py 4.3.3

**Platform**: Python 3.10 / Ubuntu 22.04

**Description**:

Hello there! When client name is set using `client_setname`, it doesn't persist after reconnection.

```python
In [3]: r = redis.Redis.from_url("redis://redis/")
In [4]: r.client_setname("test-name")
Out[4]: True
In [5]: r.client_getname()
Out[5]: 'test-name'
In [6]: r.connection_pool.disconnect()
In [7]: r.client_getname()

```

I noticed that client name persists only if it's passed to the Redis object constructor, so it's set in ConnectionPool and correctly used for new connections:

```python
In [8]: r = redis.Redis.from_url("redis://redis/", client_name="test-name")
In [9]: r.client_getname()
Out[9]: 'test-name'
In [10]: r.connection_pool.disconnect()
In [11]: r.client_getname()
Out[11]: 'test-name'
```

Is it intended behavior? If yes, maybe there should be a warning about it in documentation, because it may lead to unexpected results e.g. during debugging of connection issues.



Discussion:
Hi! This is actually the intended behaviour. We link to the documentation for [CLIENT SETNAME](https://redis.io/commands/client-setname/)  to try and help!

So, CLIENT SETNAME allows one to attach names to a client, so that using things like CLIENT LIST makes the possibility to manage clients easier (say looping through a list and issuing a CLIENT KILL).   This name only exists to the currently connected client.

If there's a documentation update that you think could help users, that would be *awesome*, and we could definitely look at merging it. WDYT?
Ok, I see this is by design - commands are executed only in the context of current connection, so common client name should be set on different layer. Actually it would be difficult to have common behavior e.g. in case of multiprocessing.

I would go with a little note in https://redis-py.readthedocs.io/en/stable/commands.html#redis.commands.core.CoreCommands.client_setname: "This method sets client name only for current connection. If you want to set a common name for all connections managed by this client, see `client_name` argument". I think it might be helpful because Client provides an abstraction that behaves like a single connection, hiding the connection management underneath.

If you agree on that, I will come back with a PR then!
@psrok1 Sounds great, waiting for a PR if you will. (LMK if not and I will do it myself)

Resolving patch:
diff --git a/redis/commands/core.py b/redis/commands/core.py
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -687,6 +687,12 @@ def client_setname(self, name: str, **kwargs) -> ResponseT:
         Sets the current connection name
 
         For more information see https://redis.io/commands/client-setname
+
+        .. note::
+           This method sets client name only for **current** connection.
+
+           If you want to set a common name for all connections managed
+           by this client, use ``client_name`` constructor argument.
         """
         return self.execute_command("CLIENT SETNAME", name, **kwargs)
 


Test patch: