python - Save the Celery task in DB- Django -


I am referring to documents

I used my proj / proj Created in celery.py , as stated in the document and then __init __. __future__ import absolute_import import from cellular import from Py

celery.py > Os.environment.setdefault ('DJANGO_SETTINGS_MODULE', 'proj.settings') application = celery (' proj ') from app.conf.update (' DatabaseBackend djcelery.backends.database ', CELERY_RESULT_BACKEND =) .config_from_object (' django.conf : Settings') app.autodiscover_tasks (lambda: settings.INSTALLED_APPS)

__ init __ py

 <. Code> __future__ import from absolute_import I have installed  pip install django-celery , then the migrated  python manage.py migrate djcelery  from the Celery Import app to celery_app   

This has made some tables in my DB.

tasks.py

  from the store imported_task import from __future__ import absolute_import request json @shared_task def post_notification (data, url): header = {'Content-Type': 'Application / JSN'} Request. Post (URL, Data = JasonDumps (Data), Header = Header)   

Then I said my work in my thoughts

  task = post_notification Print (id, url) print works.id #it prints an ID print job. Status # Printing is pending   

but none of the entries in my table

I have read my thread on SO, and many of these threads And given, but nothing happens.

Please let me know the ID & amp; How can the job be saved in DB status? Usually it should be logged in to Celery_tasacketa , but nothing in it.

Though the work is executed, but I also want to save work in DB. How can I do this? Is there anything I'm missing?

Try it in celery.py

  to __future__ import absolut_import Import celery from imported ore. Celery celery from celery. Import from schedule import crontab # Set the default Django settings module for the 'celery' program. Os.environ.setdefault ('DJANGO_SETTINGS_MODULE', 'app_name.dev_settings') App = ciliary ('app_name') # Here is a string of To be used means that the worker must not object when using the # object.apen.config_from_object ('django.conf: setting') app.autodiscover_tasks (lambda: settings.INSTALLED_APPS) app.conf.CELERY_TIMEZONE = 'UTC' app .conf.update (CELERY_RESULT_BACKEND = 'djcelery.backends.database: DatabaseBackend',)    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -