Skip to content

Commit

Permalink
Accept float values for socket_timeout
Browse files Browse the repository at this point in the history
The socket_timeout argument of redis client supports not only integers
but also floats. This allows users to pass float values[1].

[1] https://github.com/redis/redis-py/blob/1b2f408259/redis/connection.py#L1206
  • Loading branch information
kajinamit committed Mar 20, 2023
1 parent a2eea07 commit 414f01b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gnocchi/common/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
'db',
'health_check_interval',
'socket_keepalive',
])

#: Client arguments that are expected to be float convertible.
CLIENT_FLOAT_ARGS = frozenset([
'socket_timeout',
])

Expand Down Expand Up @@ -137,6 +141,8 @@ def get_client(conf, scripts=None):
v = options[a]
elif a in CLIENT_INT_ARGS:
v = int(options[a][-1])
elif a in CLIENT_FLOAT_ARGS:
v = float(options[a][-1])
else:
v = options[a][-1]
kwargs[a] = v
Expand Down

0 comments on commit 414f01b

Please sign in to comment.