abdelhadi92 / django-elasticsearch-dsl-celery Goto Github PK
View Code? Open in Web Editor NEWAllows automatic updates on the index as delayed background tasks using Celery
Allows automatic updates on the index as delayed background tasks using Celery
Software without tests is alpha. Please, add tests.
handle_delete method of the RealTimeSignalProcessor of django-elasticserach-dsl library is combined with the post_delete of the sender
But in the Celerysingalprocessor ,the delete handler this method tries to get the instance of the object from the database
which result in object does not exist error and hence the next line which deletes the object from the index won't be executed,
CelerySignalProcessor:
ObjectDoesNotExist:
or at least it is happening with me.I am not sure about the when in transaction commited,but I think celey and django transactions are independent or transaction might be commited before the celery task event starts execulting.
Possible solutions : Delete the object from the index in the pre_delete method or the outside the celery as delete is not a used that often.
Edit: This is already mentioned in the comment in the CelerySignalProcessor. So why is still in the library??
this is signals.py and added path in settings.py file and migrate without running celery or runserver
@task
def handle_savee(pk, app_label, model_name):
sender = django_apps.get_model(app_label, model_name)
instance = sender.objects.get(pk=pk)
registry.update(instance)
registry.update_related(instance)
class CelerySignalProcessor(RealTimeSignalProcessor):
def handle_save(self, sender, instance, **kwargs):
"""Handle save.
Given an individual model instance, update the object in the index.
Update the related objects either.
"""
app_label = instance._meta.app_label
model_name = instance._meta.model_name
# transaction.on_commit(lambda: handle_save.delay(instance.pk, app_label, model_name))
a = handle_savee.apply_async(args=(instance.pk, app_label, model_name))
print(a)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.