我正在尝试使用Django-Q在Django项目中创建一些预定任务。问题是,每个调度任务都失败,引发下一个异常:
'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这个时间表的名称如下:
from django_q.tasks import schedule
schedule('orders.mails.product', 2, 2, schedule_type='O')然后,在mails.py (同一文件夹)中定义了方法产品:
def product(x, y)
return x * yMy Django-q在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
}
}有人能帮忙解决这个问题吗?
发布于 2022-01-25 22:52:54
您的路径或函数似乎丢失或错了orders.mails.product。
确保那是存在的
发布于 2022-03-23 04:42:05
我相信您可能在导入方法product时遗漏了一行代码。
from .mails import product然后,当您创建时间表时,它将如下所示:
schedule(product, 2, 2, schedule_type='O')https://stackoverflow.com/questions/70723117
复制相似问题