TypeError: ‘TaskRegistry‘ object is not callable

TypeError: 'TaskRegistry' object is not callable
celery.py

#  celery.py
from __future__ import absolute_import, unicode_literals
from celery import Celery
from celery.app import app_or_default

class Scheduler(object):
    def __init__(self, app=None):
        self.app = app_or_default(app)


app = Celery("celery_tasks", broker='redis://127.0.0.1/0', backend='redis://127.0.0.1/1', include=[
    'celery_tasks.tasks',
])

app.conf.update(
    result_expires=3600,
    task_routes = {
        'celery.tasks.add': {'queue': 'hipri'},
    }
)
app.conf.timezone = 'Europe/London'

if __name__ == '__main__':
    app.start()

运行代码时,会出现下面的问题:

在celery.py文件中安装下图操作:

进入base.py文件:

处理调用时,会出现如上tasks不可调用问题,在源码中检查发现,Celery中带有的是task方法,没有tasks方法。

需要修改为@celery_app.task即可

 

TypeError: 'dict' object is not callable错误是由于函数名与变量名冲突导致的。具体来说,当我们定义了一个名为dict的变量后,调用dict()函数时就会发生冲突,并报出这个错误。要解决这个问题,我们可以删除之前定义的变量。可以使用del语句来删除变量,例如del dict。这样就能解决TypeError: 'dict' object is not callable错误了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [TypeError: ‘dict‘ object is not callable](https://blog.csdn.net/zymhhh/article/details/127705295)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Django错误:TypeError at / 'bool' object is not callable解决](https://download.csdn.net/download/weixin_38682790/12860392)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [TypeError:'dict' object is not callable](https://blog.csdn.net/qq_43199836/article/details/82937844)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值