Code Monkey home page Code Monkey logo

django-elasticsearch-dsl-celery's People

Contributors

abdelhadi92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

django-elasticsearch-dsl-celery's Issues

handle_delete

handle_delete method of the RealTimeSignalProcessor of django-elasticserach-dsl library is combined with the post_delete of the sender
Screenshot from 2021-12-13 15-13-05
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:
Screenshot from 2021-12-13 15-24-22
ObjectDoesNotExist:
Screenshot from 2021-12-13 15-25-14

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??

first time it is hanging

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.