Ulrar
Ulrar

Reputation: 983

cassandra-driver issue on shutdown

Using cassandra-driver version 3.24.0, I'm able to connect to a cluster and run queries (using protocol 4) without any issues. However when I call cluster.shutdown(), or let the script completes which calls it automatically I think, I get the following exception :

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

I couldn't find anything about this, it looks like an issue in the library itself but I assume I must be passing something it doesn't like somewhere. Any ideas what could be causing this ? Weather I use execution profiles or the legacy API, same result.

Thanks

Upvotes: 0

Views: 682

Answers (2)

shishir
shishir

Reputation: 1

I faced the same issue. I type cast the port no to int value. int(port) and issue is resolved.

Upvotes: 0

user14999985
user14999985

Reputation: 36

Have the same issue. Found that in cassandra/connection.py in row 207 there is str method, which uses port as %d. All you need is during cluster creation send int, not str

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

Upvotes: 2

Related Questions