我正在将原始帖子更改为内存泄漏,因为我发现cassandra python驱动程序不会从内存中释放会话。在重型插入过程中,它占用了所有内存(因此崩溃的cassandra没有足够的空间用于GC)。
这是之前提出的,但我也看到了最新驱动程序中的问题。
https://github.com/datastax/python-driver/pull/131
In [2]: cassandra.__version__
Out[2]: '2.1.4'
class SimpleClient(object):
session = None
def connect(self, nodes):
cluster = Cluster(nodes)
metadata = cluster.metadata
self.session = cluster.connect()
logging.info('Connected to cluster: ' + metadata.cluster_name)
for host in metadata.all_hosts():
logging.info('Datacenter: %s; Host: %s; Rack: %s', host.datacenter, host.address, host.rack)
print ("Datacenter: %s; Host: %s; Rack: %s"%(host.datacenter, host.address, host.rack))
def close(self):
self.session.cluster.shutdown()
logging.info('Connection closed.')
def main():
logging.basicConfig()
client = SimpleClient()
client.connect(['127.0.0.1'])
client.close()
if __name__ == "__main__":
count = 0
while count != 1:
main()
time.sleep(1)
如果有人找到了解决方案,请分享。