You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Celery启动Beat报AttributeError: 'int' object has no attribute 'upper'错误

问题根因

你的代码中beat_schedule配置存在语法错误,触发了Celery的参数解析逻辑异常:
Celery要求定时任务的args字段必须是列表/元组类型,用来对应任务函数接收的多个参数。你当前直接传入了字符串'Dedeler',Celery在解析配置时会错误遍历字符串的每个字符,同时触发底层参数类型校验异常,就是你看到的'int' object has no attribute 'upper'报错。这个规则是Celery原生要求,和你使用的Heroku Celery发行版无关。

注意:单元素元组必须加末尾逗号,否则会被识别为普通变量,比如('Dedeler')仍然是字符串类型,('Dedeler',)才是合法的单元素元组。

修复后的tasks.py代码

from celery import Celery

app = Celery('tasks',broker='xxxxxxxxxxx')


app.conf.timezone = 'UTC'

app.conf.beat_schedule = {
    'add-every-10-seconds': {
        'task': 'tasks.test',
        'schedule': 10.0,
        # 将字符串修改为单元素元组
        'args': ('Dedeler',)
    },
}


@app.task
def test(arg):
    print(arg)

验证方法

修改代码后重新执行Beat启动命令即可:
celery -A tasks beat

如果仍有异常,可以在启动命令加上日志级别参数排查问题:
celery -A tasks beat -l INFO

内容的提问来源于stack exchange,提问作者Mehmet Alp Albayraktaroğlu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 12:15:02