Cassandra valueError:contact_points,endpoint_factory,ssl_context和ssl_options不能使用云配置指定
我是Cassandra的新手,并试图将其与芹菜任务队列一起使用。
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
当我将作业发送给芹菜工人时,我会收到以下错误,
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
我可以连接到Cassandra群集,因为没有任何问题,
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()
有人可以建议如何与芹菜正确使用Cassandra吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以找到一项演练,可以将芹菜连接到dataStax astra
这是您的配置的样子
You can find a walkthrough to connect Celery to Datastax Astra here
This is what your configuration should look like