关闭cassandra集群和会话时出现问题

时间:2018-04-12 06:39:48

标签: python cassandra cassandra-2.0 cassandra-driver

Cassandra 2.1.15.1403 | DSE 4.8.9

Cassandra驱动程序测试:2.1.2和3.1.7

我们正在使用python脚本迁移其中一个表中的某些数据。完成此操作后,我们将使用以下方式关闭连接:

if (None != self.session):
    self.session.shutdown()
if (None != self.cluster):
    self.cluster.shutdown()

我们在群集关闭时得到以下异常:

DEBUG: Closed socket to 127.0.0.1
DEBUG: Asyncore event loop stopped unexepectedly
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/cassandra/io/asyncorereactor.py", line 91, in _run_loop
    asyncore.loop(timeout=0.001, use_poll=True, count=1000)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 220, in loop
    poll_fun(timeout, map)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 145, in poll
    r, w, e = select.select(r, w, e, timeout)
error: (9, 'Bad file descriptor')
DEBUG: Asyncore event loop ended

如果我们删除session.shutdown,它可以正常工作。有人对此有所了解吗?

1 个答案:

答案 0 :(得分:0)

cluster.shutdown()已经在做session.shutdown http://datastax.github.io/python-driver/_modules/cassandra/cluster.html#Cluster.shutdown所以我认为没有必要明确地执行会话关闭。