Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用redis py中的管道设置等待响应的redis超时?_Python_Redis_Response_Pipeline_Redis Py - Fatal编程技术网

Python 如何使用redis py中的管道设置等待响应的redis超时?

Python 如何使用redis py中的管道设置等待响应的redis超时?,python,redis,response,pipeline,redis-py,Python,Redis,Response,Pipeline,Redis Py,在下面的代码中,管道超时是否为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.exec

在下面的代码中,管道超时是否为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',)
如果我将套接字超时值修改为10,它将返回ok。
参数“套接字超时”不意味着连接超时吗?但它看起来像是响应超时

redis py版本是2.6.7

这不是连接超时,而是操作超时。在内部,StricRedis()上的socket_timeout参数将传递给套接字的settimeout方法

详细信息请参见此处:

我在github上询问了redis py的作者,如下所示:


如果您使用的是redis py,则取决于redis-py的版本