关闭时的 cassandra 驱动程序问题

cassandra-driver issue on shutdown

使用 cassandra-driver 版本 3.24.0,我能够毫无问题地连接到集群和 运行 查询(使用协议 4)。 但是,当我调用 cluster.shutdown(),或者让脚本完成时我认为自动调用它,我得到以下异常:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "cassandra\cluster.py", line 221, in cassandra.cluster._shutdown_clusters
  File "cassandra\cluster.py", line 1759, in cassandra.cluster.Cluster.shutdown
  File "cassandra\cluster.py", line 3147, in cassandra.cluster.Session.shutdown
  File "cassandra\pool.py", line 493, in cassandra.pool.HostConnection.shutdown
  File "C:\Users\myuser\AppData\Local\Programs\Python\Python37\lib\site-packages\cassandra\io\asyncorereactor.py", line 386, in close
    ConnectionShutdown("Connection to %s was closed" % self.endpoint))
  File "cassandra\connection.py", line 207, in cassandra.connection.DefaultEndPoint.__str__
TypeError: %d format: a number is required, not str

我找不到任何相关信息,它看起来像是库本身的问题,但我想我一定是在传递一些它不喜欢的东西。 任何想法可能是什么原因造成的? Weather I use execution profiles or the legacy API, 同样的结果。

谢谢

有同样的问题。 发现在cassandra/connection.py中第207行有str方法,使用端口为%d。您只需要在集群创建期间发送 int,而不是 str

cluster = Cluster(contact_points=[hostname], port=int(port), execution_profiles=profiles, auth_provider=auth)

我遇到了同样的问题。我键入将端口号转换为 int 值。 int(端口),问题已解决。