Pol Rodoreda
Pol Rodoreda

Reputation: 33

Django-Q schedule nonetype error with custom function

I'm trying to create some scheduled tasks in my Django project using Django-Q. The problem is that every schedule task fails raising next exception:

'NoneType' object is not callable : Traceback (most recent call last):
File "/home/ubuntu/.virtualenvs/gamesquare-pre/lib/python3.6/site-packages/django_q/cluster.py", line 432, in worker
res = f(*task["args"], **task["kwargs"])
TypeError: 'NoneType' object is not callable

The schedule is called like:

from django_q.tasks import schedule

schedule('orders.mails.product', 2, 2, schedule_type='O')

Then, in mails.py (same folder) I have the method product defined:

def product(x, y)
    return x * y

My Django-Q's configuration in settings.py:

Q_CLUSTER = {
    'name': 'qclust',
    'workers': config('Q_CLUSTER_WORKERS', cast=int),
    'timeout': 20,
    'cpu_affinity': 1,
    'save_limit': 50,
    'queue_limit': 100,
    'redis': {
        'host': 'localhost',
        'port': 6379,
        'db': 0
    }
}

Can anyone help with this issue?

Upvotes: 2

Views: 1480

Answers (2)

CRAZYchip98
CRAZYchip98

Reputation: 1

I believe you might be missing a line of code at the beginning to import the method product:

from .mails import product

Then when you create the schedule it would look like this:

schedule(product, 2, 2, schedule_type='O')

Upvotes: 0

Jinal Patel
Jinal Patel

Reputation: 21

your path or function seems to be missing or wrong orders.mails.product

make sure that exists

Upvotes: 2

Related Questions