我正在运行Celery 2.2.4/djCelery 2.2.4,使用RabbitMQ 2.1.1作为后端.我最近在网上带来了两台新的芹菜服务器 - 我在两台机器上运行了2名工作人员,总共有18个线程,在我的新加工盒子上(36g RAM +双超线程四核),我正在运行10每个都有8个线程的工作者,总共180个线程 - 我的任务都很小,所以这应该没问题.
过去几天节点一直运行良好,但今天我注意到它.delaay()正在悬挂.当我打断它时,我看到一个指向这里的追溯:
File "/home/django/deployed/releases/20110608183345/virtual-env/lib/python2.5/site-packages/celery/task/base.py", line 324, in delay
return self.apply_async(args, kwargs)
File "/home/django/deployed/releases/20110608183345/virtual-env/lib/python2.5/site-packages/celery/task/base.py", line 449, in apply_async
publish.close()
File "/home/django/deployed/virtual-env/lib/python2.5/site-packages/kombu/compat.py", line 108, in close
self.backend.close()
File "/home/django/deployed/virtual-env/lib/python2.5/site-packages/amqplib/client_0_8/channel.py", line 194, in close
(20, 41), # Channel.close_ok
File "/home/django/deployed/virtual-env/lib/python2.5/site-packages/amqplib/client_0_8/abstract_channel.py", line 89, in wait
self.channel_id, allowed_methods)
File "/home/django/deployed/virtual-env/lib/python2.5/site-packages/amqplib/client_0_8/connection.py", line 198, in _wait_method
self.method_reader.read_method()
File "/home/django/deployed/virtual-env/lib/python2.5/site-packages/amqplib/client_0_8/method_framing.py", line 212, in read_method
self._next_method()
File "/home/django/deployed/virtual-env/lib/python2.5/site-packages/amqplib/client_0_8/method_framing.py", line 127, in _next_method
frame_type, channel, payload = self.source.read_frame()
File …Run Code Online (Sandbox Code Playgroud) 我创建了一个具有以下目录结构的芹菜应用程序(如芹菜网站中所示):
proj
|-- celery.py
|-- celery.pyc
|-- __init__.py
|-- __init__.pyc
|-- tasks.py
`-- tasks.pyc
Run Code Online (Sandbox Code Playgroud)
以下是celery.py的内容
from __future__ import absolute_import
from celery import Celery
app = Celery('proj',
broker='amqp://rabbitmquser:<my_passowrd>@localhost:5672/localvhost',
#backend='amqp://',
include=['proj.tasks'])
# Optional configuration, see the application user guide.
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
)
if __name__ == '__main__':
app.start()
Run Code Online (Sandbox Code Playgroud)
以下是tasks.py的内容
from __future__ import absolute_import
from proj.celery import app
@app.task
def add(x, y):
return x + y
@app.task
def mul(x, y):
return x * y
@app.task
def xsum(numbers):
return sum(numbers)
Run Code Online (Sandbox Code Playgroud)
现在我用以下命令启动芹菜工作者:
celery -A proj worker …Run Code Online (Sandbox Code Playgroud)