I am new to cassandra and trying to use it with celery task queue.
import json
from cassandra.auth import PlainTextAuthProvider
from celery import Celery
from config_constant import REDIS_CONNECTION
app = Celery('tasks', broker=REDIS_CONNECTION,
result_backend='cassandra',
result_extended=True)
cassandra_options = {
'cloud': {
'secure_connect_bundle': 'path/to/astra-secure-connect.zip'
}
}
client_id_config = json.load(open('path/to/client_id_secret.json'))
app.conf.update(
cassandra_options=cassandra_options,
cassandra_keyspace='my_keyspace',
cassandra_table='my_table',
cassandra_servers=['myserver.db.astra.datastax.com:29080'],
cassandra_auth_provider=PlainTextAuthProvider(client_id_config['client_id'], client_id_config['client_secret'])
)
@app.task
def repeated_squaring(x: int, y: int):
power = 1
while y:
power = power * x * x
if x % 2 != 0:
power *= x
y //= 2
return x, y, power
when I send jobs to celery worker I get the below error
File "cassandra/cluster.py", line 1120, in cassandra.cluster.Cluster.__init__
ValueError: contact_points, endpoint_factory, ssl_context, and ssl_options cannot be specified with a cloud configuration
I can connect to the cassandra cluster as below without any issue
cloud_config = {
'secure_connect_bundle': 'path/to/astra-secure-connect.zip'
}
client_id_config = json.load(open('path/to/client_id_secret.json'))
auth_provider = PlainTextAuthProvider(client_id_config['client_id'], client_id_config['client_secret'])
cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider)
session = cluster.connect()
can someone suggest how to use cassandra correctly with celery?