1

I have problem with django, celery and rabbitmq.

I use celery to send messages to FCM devices, but problem is that celery doesn't run that FCM command for sending messages, until I restart celery server.

And when I restart celery, and try again, still same, I need to restart it again after every action.

Example code:

from __future__ import absolute_import, unicode_literals

from celery import shared_task
# firebase cloud messaging
from fcm.utils import get_device_model
Device = get_device_model()


@shared_task
def send_firebase_message(json, **kwargs):
    response = Device.send_msg(json, **kwargs)
    return response

This is simple code, so this Device.send_msg doesn't fire until I restart celery server. So, celery doesn't do this task until i restart it. Maybe it is rabbitmq problem?

Anyone got any solution for this? What can be the problem?

Mirza Delic
  • 4,119
  • 12
  • 55
  • 86
  • Sounds like you need to clean Celery after every use. Try something like this: ***$celery purge*** – Ess Kay Sep 13 '17 at 13:01
  • But that is bad if I need to do it for every action? – Mirza Delic Sep 13 '17 at 13:04
  • Doubt it. I call garbage collection in all my projects. especially when I use components. Otherwise things get stuck in RAM, create memory leaks, or like in your case, block processes. Even if it is not the issue, Its a good practice – Ess Kay Sep 13 '17 at 13:24
  • See here: https://stackoverflow.com/questions/7149074/deleting-all-pending-tasks-in-celery-rabbitmq – Ess Kay Sep 13 '17 at 13:57

1 Answers1

0

The --autoreload not working since 3.1, change to non-blocking inotify neededl

if you want know more refer the doc deprecated

we have another option do this , refer this post auto reload.It seems working for my current projects

Robert
  • 3,373
  • 1
  • 18
  • 34
  • But i don't have problem with autoreload, celery is not working until i restart server, i don't change code, just add task to celery and it doesn't fire until restart. – Mirza Delic Sep 13 '17 at 13:13