我无法使芹菜(版本4.0.2)与RabbitMQ一起使用。我在一个tasks.py文件中有以下内容(如芹菜的教程/文档中所建议):
from celery import Celery
app = Celery('tasks', broker='pyamqp://guest@localhost//')
@app.task
def add(x, y):
return x + y
但是,当我按下此命令时:
celery -A tasks worker --loglevel=info
我得到以下怪异错误:
Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 22] Invalid argument.
我的RabbitMQ服务器正在运行。这是我按" rabbitmqctl状态"命令时得到的:
[{pid,188},
{running_applications,[{rabbit,"RabbitMQ","3.6.6"},
{os_mon,"CPO CXC 138 46","2.2.14"},
{rabbit_common,[],"3.6.6"},
{mnesia,"MNESIA CXC 138 12","4.11"},
{xmerl,"XML parser","1.3.5"},
{ranch,"Socket acceptor pool for TCP protocols.",
"1.2.1"},
{sasl,"SASL CXC 138 11","2.3.4"},
{stdlib,"ERTS CXC 138 10","1.19.4"},
{kernel,"ERTS CXC 138 10","2.16.4"}]},
{os,{unix,linux}},
{erlang_version,"Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:64] [kernel-poll:true]n"},
{memory,[{total,45625464},
{connection_readers,0},
{connection_writers,0},
{connection_channels,0},
{connection_other,0},
{queue_procs,2704},
{queue_slave_procs,0},
{plugins,0},
{other_proc,18736352},
{mnesia,60216},
{mgmt_db,0},
{msg_index,51568},
{other_ets,933528},
{binary,1069976},
{code,19343063},
{atom,711569},
{other_system,4716488}]},
{alarms,[]},
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
{vm_memory_high_watermark,0.4},
{vm_memory_limit,6819561472},
{disk_free_limit,50000000},
{disk_free,188958461952},
{file_descriptors,[{total_limit,1948},
{total_used,2},
{sockets_limit,1751},
{sockets_used,0}]},
{processes,[{limit,1048576},{used,141}]},
{run_queue,0},
{uptime,1138},
{kernel,{net_ticktime,60}}]
我也使用Python 2.7。有人知道可能是什么问题吗?
似乎某个地方有一个错误。我可以通过运行"芹菜AMPQ"来遇到错误的痕迹:
...
File "/usr/local/lib/python2.7/dist-packages/amqp/transport.py", line 194, in <dictcomp>
opt: sock.getsockopt(SOL_TCP, opt) for opt in TCP_OPTS
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 22] Invalid argument
我已经将芹菜降至3.1.23版,现在正常工作。问题可能来自我在与Windows 10集成的Ubuntu版本上使用芹菜的事实(通常仍然认为这是"真实的" Ubuntu)。