django - celery 调度错误: an integer is required

标签 django heroku redis celery

我在 Heroku 上使用 Celery,Redis 作为我的代理。我也尝试过将 RabbitMQ 作为代理,但在尝试运行计划任务时不断出现以下错误:

Traceback (most recent call last): 
  File "/app/.heroku/python/lib/python2.7/site-packages/celery/beat.py", line 203, in maybe_due 
    result = self.apply_async(entry, publisher=publisher) 
  File "/app/.heroku/python/lib/python2.7/site-packages/celery/beat.py", line 259, in apply_async 
    entry, exc=exc)), sys.exc_info()[2]) 
  File "/app/.heroku/python/lib/python2.7/site-packages/celery/beat.py", line 251, in apply_async 
    **entry.options) 
  File "/app/.heroku/python/lib/python2.7/site-packages/celery/app/task.py", line 555, in apply_async 
    **dict(self._get_exec_options(), **options) 
  File "/app/.heroku/python/lib/python2.7/site-packages/celery/app/base.py", line 347, in send_task 
    with self.producer_or_acquire(producer) as P: 
  File "/app/.heroku/python/lib/python2.7/site-packages/celery/app/base.py", line 402, in producer_or_acquire 
    producer, self.amqp.producer_pool.acquire, block=True, 
  File "/app/.heroku/python/lib/python2.7/site-packages/celery/app/amqp.py", line 492, in producer_pool 
    self.app.pool, 
  File "/app/.heroku/python/lib/python2.7/site-packages/celery/app/base.py", line 608, in pool 
    self._pool = self.connection().Pool(limit=limit) 
  File "/app/.heroku/python/lib/python2.7/site-packages/kombu/connection.py", line 612, in Pool 
    return ConnectionPool(self, limit, preload) 
  File "/app/.heroku/python/lib/python2.7/site-packages/kombu/connection.py", line 987, in __init__ 
    preload=preload) 
  File "/app/.heroku/python/lib/python2.7/site-packages/kombu/connection.py", line 833, in __init__ 
    self.setup() 
  File "/app/.heroku/python/lib/python2.7/site-packages/kombu/connection.py", line 1011, in setup 
    for i in range(self.limit): 
SchedulingError: Couldn't apply scheduled task my_task: an integer is required 

我的任务是这样写的:

@app.task(ignore_result=True)
def my_task():
    do_something()

有什么想法吗?

最佳答案

我突然想到发生了什么事。在我的设置文件中,我有以下行:

BROKER_POOL_LIMIT = os.environ.get('BROKER_POOL_LIMIT', 1)

我应该强制它是一个整数:

BROKER_POOL_LIMIT = int(os.environ.get('BROKER_POOL_LIMIT', 1))

关于django - celery 调度错误: an integer is required,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26498244/

相关文章:

ruby - Sidekiq - 查看完成的作业

java - Spring Boot 2.0 中的 RedisCacheManager.setCacheNames

python - 数据结构 python django

node.js - npm ERR cb() 从未调用

python - 如何从处理中排除 Django 模板文件的一部分?

python - 在 heroku 上运行 flask-migrate 会产生错误

ruby - Heroku 上的 OpenSSL 1.0.1

redis - StackExchange.Redis API : ListLeftPopAsync is taking infinite time or timing out

Django - 是否可以直接在设置文件中从云服务加载 secret /密码/动态值

python - 如何使用 Django 处理 Assets (css、js 等)?