【发布时间】:2015-09-26 14:44:14
【问题描述】:
我正在使用 Datastax 提供的 Python Cassandra 驱动程序连接到单节点 Cassandra 实例。我的 Python 代码生成了多个进程(使用 multiprocessing 模块),每个进程都会打开到该节点的连接,并在退出时将其关闭。
这是我观察到的行为:当生成的进程数较少(比如 ~ 30)时,我的代码运行完美。但如果数量更多,我会看到这样的错误(可能并不奇怪):
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 755, in connect
self.control_connection.connect()
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1868, in connect
self._set_new_connection(self._reconnect_internal())
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1903, in _reconnect_internal
raise NoHostAvailable("Unable to connect to any servers", errors)
NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': error(99, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Cannot assign requested address")})
显然,主机无法接受新连接。这看起来应该由驱动程序或 Cassandra 处理 - 通过让新的连接请求排队并在它释放时授予它们。
我如何强加这种行为?
【问题讨论】:
标签: python-2.7 cassandra-2.0 datastax