I have now got django and celery working. but there is no logs print for me to check if the task is working correctly. I am using mac and plan to use celery on production in my ubuntu aws machine.
Here is what i do in tasks.py:
import string
from celery import shared_task
import logging
@shared_task
def send_push_notification_celery(total):
logging.debug("send_push_notification_celery")
logging.debug("total:%d", total)
return "i love you"
this is all that gets printed out on celery worker console:
[2018-04-12 11:25:08,620: INFO/MainProcess] Received task: myapp.tasks.send_push_notification_celery[322eae85-3ef7-4adb-b3bd-eae90300587b]
[2018-04-12 11:25:08,622: INFO/ForkPoolWorker-2] Task myapp.tasks.send_push_notification_celery[322eae85-3ef7-4adb-b3bd-eae90300587b] succeeded in 0.0001755820121616125s: 'i love you'
You can use normal python print to output data into console from celery task:
def send_push_notification_celery(total):
print("send_push_notification_celery")
print("total:%d", total)
return "i love you"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With