Describe the bug
Hello, my friend
Thank you for your hard work in creating this wonderful library.
I have one small question
The behavior I'm seeing is that when I run the celery task, Observer doesn't work as I expect. When changing a task through the Django admin panel, everything works fine, the model change is immediately sent to my websocket, but when I run the task in celery, the notifications disappear.
I tried to find the reason for 2 days but without success
I hope you can help me, my friend!
To Reproduce
I won’t go into too much depth, I’ll describe the main points, they will be enough to understand the essence of the problem
Describe the bug Hello, my friend Thank you for your hard work in creating this wonderful library. I have one small question The behavior I'm seeing is that when I run the celery task, Observer doesn't work as I expect. When changing a task through the Django admin panel, everything works fine, the model change is immediately sent to my websocket, but when I run the task in celery, the notifications disappear. I tried to find the reason for 2 days but without success I hope you can help me, my friend!
To Reproduce I won’t go into too much depth, I’ll describe the main points, they will be enough to understand the essence of the problem
docker compose ` ...etc... redis: image: redis:alpine container_name: redis_development ports:
...etc... `
Settings ` CELERY_BROKER_URL = 'redis://redis:6379/0' CELERY_RESULT_BACKEND = 'redis://redis:6379/0'
Channels
CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { 'hosts': ['redis://redis:6379/0'], }, }, } `
Consumer `class StudyConsumer(ObserverModelInstanceMixin, GenericAsyncAPIConsumer, PatchModelMixin): queryset = Study.objects.all() serializer_class = StudiesSerializer
Celery task:
def run(pk: str): study_record = Study.objects.get(id=pk) study_record.completed_at = datetime.datetime.now() study_record.status = Study.COMPLETED study_record.save(update_fields=['processing_time', 'result', 'status', 'started_at', 'completed_at']) return 'A processing celery task was complete!'
Expected behavior I'm guessing that changes inside the celery task should also fire an observer trigger and be sent to Websocket
Thanks for any answer Good luck!