Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.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 2.7 Cassandra python驱动程序:客户端请求超时_Python 2.7_Cassandra_Datastax - Fatal编程技术网

Python 2.7 Cassandra python驱动程序:客户端请求超时

Python 2.7 Cassandra python驱动程序:客户端请求超时,python-2.7,cassandra,datastax,Python 2.7,Cassandra,Datastax,我设置了一个简单的脚本,将新记录插入Cassandra数据库。它在我的本地机器上运行良好,但当我将数据库移动到远程机器时,客户端会出现超时错误。如何正确设置此驱动程序的超时?我试过很多东西。我在IDE中破解了超时,并让它在没有超时的情况下工作,因此我确信这只是一个超时问题 如何设置群集: profile = ExecutionProfile(request_timeout=100000) self.cluster = Cluster([os.getenv('CASSANDRA_NODES', N

我设置了一个简单的脚本,将新记录插入Cassandra数据库。它在我的本地机器上运行良好,但当我将数据库移动到远程机器时,客户端会出现超时错误。如何正确设置此驱动程序的超时?我试过很多东西。我在IDE中破解了超时,并让它在没有超时的情况下工作,因此我确信这只是一个超时问题

如何设置群集:

profile = ExecutionProfile(request_timeout=100000)
self.cluster = Cluster([os.getenv('CASSANDRA_NODES', None)], auth_provider=auth_provider,
                       execution_profiles={EXEC_PROFILE_DEFAULT: profile})
connection.setup(hosts=[os.getenv('CASSANDRA_SEED', None)],
                 default_keyspace=os.getenv('KEYSPACE', None),
                 consistency=int(os.getenv('CASSANDRA_SESSION_CONSISTENCY', 1)), auth_provider=auth_provider,
                 connect_timeout=200)

session = self.cluster.connect()
我正在尝试执行的查询:

    model = Model.create(buffer=_buffer, lock=False, version=self.version)
13..':'客户端请求超时。请参阅Session.execute_async'},last_host=54.213


我插入的记录是11mb,所以我可以理解有延迟,只是增加超时时间就可以了,但我似乎无法理解

您可以在群集构造函数中设置请求超时:

self.cluster = Cluster([os.getenv('CASSANDRA_NODES', None)], 
                       auth_provider=auth_provider,
                       execution_profiles={EXEC_PROFILE_DEFAULT: profile},
                       request_timeout=10)

参考:

根据文档,
request\u timeout
是的属性,您可以向集群构造函数()提供执行配置文件

因此,您可以:

来自cassandra.cluster导入集群
从cassandra.cluster导入ExecutionProfile
执行配置文件=执行配置文件(请求超时=600)
profiles={'node1':执行_profile}
cluster=cluster([os.getenv('CASSANDRA_NODES',None)],execution_profiles=profiles)
session=cluster.connect()
session.execute('SELECT*FROM test',execution_profile='node1')

重要:当您使用
execute
èxecute_async
时,必须指定
execute_配置文件
名称。

默认请求超时是会话对象的一个属性(驱动程序的2.0.0版及更高版本)

这是最简单的答案(不需要乱弄执行配置文件),我已经确认它是有效的


您不能,这是一个意外的参数,它会出错。@MarkJones您可能正在旧版本上尝试它?这对我来说很好,我甚至在源代码中看到了这个论点。
session = cluster.connect(keyspace)
session.default_timeout = 60