Replies: 1 comment 4 replies
-
@samul-1 when your updating the model from Celary im assuming you doing this through a django model rather than poking directly at the DB? You'r correct in that that the signal might not be being detected, this will happen if your celery code path does not import your consumer. Since python is interpreted that module that containers your consumer needs to end up being imprecated so that the signal handler is registered. To solve this you will need to add an import statement to your celery entry point that imports your consumer model to ensure they are registered? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Just recently started using this library and I'm loving it!
I am working on an app that allows users to submit JS code to solve puzzles. The code is executed inside node's vm2 module which allows for safe and sandboxed execution.
I have a model with a JSONField which represents the outcome of the user-submitted code execution. That data is returned by node. The actual execution of vm2 is done inside of a Celery task, in which
subprocess.check_output
is called on the node script passing in the user code. After node is done, the returned details object is saved to the aforementioned JSONField.I made a consumer that inherits from
ObserverModelInstanceMixin
in order to observe changes to instances of that model, therefore receiving the results on my app's frontend. The flow is as follows: frontend subscribes to the results instance by connecting to the consumer -> frontend triggers code execution -> Celery task saves results to field on the observed instance.Expected behavior: a message should be fired by my consumer notifying the frontend of the change on the results field in the observed instance.
Actual behavior: no such message is fired.
I'm assuming my setup is sound, as I tried changing fields on the instance from other spots of the application that don't use Celery and the update messages do get sent.
I'm assuming it has something to do with the fact that the change to the model is async and Django signals don't react appropriately.
Is there a way to work around this? Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions