Celery SchedulingError:需要一个整数

时间:2014-10-21 23:45:46

标签: 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()

任何想法会发生什么?

1 个答案:

答案 0 :(得分:1)

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

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

我应该强迫这是一个整数:

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