gpt4 book ai didi

python - 如何在redis-py中设置等待管道响应的redis超时?

转载 作者:IT王子 更新时间:2023-10-29 05:56:13 25 4
gpt4 key购买 nike

在下面的代码中,管道超时是否为 2 秒?

client = redis.StrictRedis(host=host, port=port, db=0, socket_timeout=2)
pipe = client.pipeline(transaction=False)
for name in namelist:
key = "%s-%s-%s-%s" % (key_sub1, key_sub2, name, key_sub3)
pipe.smembers(key)
pipe.execute()

在redis中,集合“key”中有很多成员。它总是返回如下代码最后的错误:

error Error while reading from socket: ('timed out',)

如果我修改 socket_timeout 值为 10,它返回 ok。
参数“socket_timeout”不是表示连接超时吗?但它看起来像响应超时。
redis-py版本为2.6.7。

最佳答案

我问了andymccurdy ,redis-py 的作者,在 github 和 the answer如下:

If you're using redis-py<=2.9.1, socket_timeout is both the timeout for socket connection and the timeout for reading/writing to the socket. I pushed a change recently (465e74d) that introduces a new option, socket_connect_timeout. This allows you to specify different timeout values for socket.connect() differently from socket.send/socket.recv(). This change will be included in 2.10 which is set to be released later this week.

redis-py版本是2.6.7,所以是socket连接超时和socket读写超时。

关于python - 如何在redis-py中设置等待管道响应的redis超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23930125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com