Skip to content

Client name doesn't persist after lost connection when set using client_setname #2245

@psrok1

Description

@psrok1

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.

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions