python - Save the Celery task in DB- Django -
I am referring to documents
I used my celery.py >> __ init __ py This has made some tables in my DB. tasks.py Then I said my work in my thoughts 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 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 proj / proj Created in
celery.py , as stated in the document and then
__init __. __future__ import absolute_import import from cellular import from 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) <. 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
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)
task = post_notification Print (id, url) print works.id #it prints an ID print job. Status # Printing is pending
Celery_tasacketa , but nothing in it.
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
Post a Comment