Open TvoroG opened 10 years ago
unfortunately the solution in the link is pretty much the best way to deal with python-driver long-lived session and celery pre-fork. How often do you get the timeout? did you already check cassandra logs?
Almost every attempt to follow. I didn't find anything useful in cassandra logs. Thanks for help! I just wanted to know whether there is a better solution or not.
I think that I'm getting this error -- unfortunately the original link to the cqlengine issue is now dead ( https://github.com/cqlengine/cqlengine/issues/237 ) -- does anybody have any memory as to the workaround in that link?
something like this:
import threading
from django.conf import settings
from cassandra.cluster import Cluster
from celery.signals import worker_process_init,worker_process_shutdown
thread_local = threading.local()
@worker_process_init.connect
def open_cassandra_session(*args, **kwargs):
cluster = Cluster([settings.DATABASES["cassandra"]["HOST"],], protocol_version=3)
session = cluster.connect(settings.DATABASES["cassandra"]["NAME"])
thread_local.cassandra_session = session
@worker_process_shutdown.connect
def close_cassandra_session(*args,**kwargs):
session = thread_local.cassandra_session
session.shutdown()
thread_local.cassandra_session = None
We should probably add this to the documentation of the library and hook it up own cassandra connection setup() functions.
A blog post with a similar issue and solution can be found here: http://robertolopes.me/2015/07/operationtimedout-exception-raised-when-using-the-cassandra-driver-for-python-in-conjunction-with-celery-delayed-tasks/ And sometimes tests are failing for us because of this: https://travis-ci.org/JelteF/Stream-Framework/jobs/168539883
I think we should add this to the docs and perhaps wrap it up somehow with an helper function. If you use stream-framework with Cassandra you will have this problem for sure.
Hello!
When I try to follow user insert queries return the following error:
I found this solution: https://github.com/cqlengine/cqlengine/issues/237 but it's crude. How you deal with this problem?