Problem with Celery and Django/Python

Asked

Viewed 196 times

0

I am trying to implement a tasks system with Celery in Django, but it is giving error and I do not know how to solve...

Error that appears on console:

inserir a descrição da imagem aqui

tasks py.

from __future__ import absolute_import, unicode_literals
from celery import task

from datetime import date



@task(ignore_result=True)
def verify_post_date(string):
    print(string)

py Settings.

from celery.schedules import crontab
from datetime import timedelta


CELERY_ALWAYS_EAGER = True
CELERY_BROKER_URL = 'redis://localhost:6379/0'
#CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_TIMEZONE = 'America/Sao_Paulo'
CELERY_BEAT_SCHEDULE = {

    'verify_post_date': {
        'task': 'core.verify_post_date',
        'schedule': timedelta(seconds=10),

    },

}

1 answer

0

Your task takes a string parameter. So, to schedule it, you must pass this parameter through the args key, as below:

'verify_post_date': {
    'task': 'core.verify_post_date',
    'schedule': timedelta(seconds=10),
    'args': ('teste')
}

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.