skip to Main Content

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?

2

Answers


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

    make sure that exists

    Login or Signup to reply.
  2. 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')
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search