在下面的代码中,管道超时是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。
参数“socket_timeout”不表示连接超时吗?但看起来像是响应超时。
redis py版本是2.6.7。
不是连接超时,是操作超时。在内部,stricredis()上的socket_timeout参数将传递给套接字的settimeout方法。
详细信息请参见:https://docs.python.org/2/library/socket.html#socket.socket.settimeout
我问andymccurdy,redis py的作者,关于github和the answer如下:
redis py版本是2.6.7,所以它既是套接字连接的超时,也是对套接字的读写超时。
相关问题 更多 >
编程相关推荐