- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试将我的任务发送到代理 (RabbitMQ) 时,它挂起。
# python shell
promise = foo.s(first_arg="2").apply_async()
# blocking indefinitely. I expected a promise object.
如果我同步运行任务,它会按预期工作。
# python shell
promise = foo.s(first_arg="2").apply()
>>> hello argument 2
如果我打断
.apply_async()
使用 ctrl+c 我得到了一些线索的回溯:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 32, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/amqp/transport.py", line 173, in _connect
host, port, family, socket.SOCK_STREAM, SOL_TCP)
File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -9] Address family for hostname not supported
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 325, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 866, in _connection_factory
self._connection = self._establish_connection()
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 801, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/python3.7/site-packages/kombu/transport/pyamqp.py", line 128, in establish_connection
conn.connect()
File "/usr/local/lib/python3.7/site-packages/amqp/connection.py", line 323, in connect
self.transport.connect()
File "/usr/local/lib/python3.7/site-packages/amqp/transport.py", line 113, in connect
self._connect(self.host, self.port, self.connect_timeout)
File "/usr/local/lib/python3.7/site-packages/amqp/transport.py", line 184, in _connect
"failed to resolve broker hostname"))
File "/usr/local/lib/python3.7/site-packages/amqp/transport.py", line 197, in _connect
self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/celery/canvas.py", line 225, in apply_async
return _apply(args, kwargs, **options)
File "/usr/local/lib/python3.7/site-packages/celery/app/task.py", line 565, in apply_async
**options
File "/usr/local/lib/python3.7/site-packages/celery/app/base.py", line 749, in send_task
amqp.send_task_message(P, name, message, **options)
File "/usr/local/lib/python3.7/site-packages/celery/app/amqp.py", line 532, in send_task_message
**properties
File "/usr/local/lib/python3.7/site-packages/kombu/messaging.py", line 178, in publish
exchange_name, declare,
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 525, in _ensured
return fun(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/kombu/messaging.py", line 184, in _publish
channel = self.channel
File "/usr/local/lib/python3.7/site-packages/kombu/messaging.py", line 206, in _get_channel
channel = self._channel = channel()
File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 34, in __call__
value = self.__value__ = self.__contract__()
File "/usr/local/lib/python3.7/site-packages/kombu/messaging.py", line 221, in <lambda>
channel = ChannelPromise(lambda: connection.default_channel)
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 884, in default_channel
self._ensure_connection(**conn_opts)
File "/usr/local/lib/python3.7/site-packages/kombu/connection.py", line 439, in _ensure_connection
callback, timeout=timeout
File "/usr/local/lib/python3.7/site-packages/kombu/utils/functional.py", line 339, in retry_over_time
sleep(1.0)
代理连接字符串在系统中如下所示:
~$ env | grep BROKER
CELERY_BROKER=pyamqp://guest@172.23.0.3//
python中的代理连接字符串:
# python shell
from src.celery import app
app.pool.connection
>>> Connection: amqp://guest:**@localhost:5672//
之前提示RabbitMQ没有运行,或者连接串坏了;我的 celery worker (消费者)进程能够使用相同的连接字符串进行连接。
-------------- celery@f9ab48fc6b63 v5.0.5 (singularity)
--- ***** -----
-- ******* ---- Linux-4.15.0-20-generic-x86_64-with-debian-9.12 2021-03-05 07:56:29
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app: celery_statst_api:0x7f15b6de0450
- ** ---------- .> transport: amqp://guest:**@my-rabbit:5672//
- ** ---------- .> results: postgresql://docker:**@pg_db:5432/
- *** --- * --- .> concurrency: 16 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
[tasks]
. foo_task
. (long list of tasks)
[2021-03-05 07:56:30,564: INFO/MainProcess] Connected to amqp://guest:**@my-rabbit:5672//
[2021-03-05 07:56:30,581: INFO/MainProcess] mingle: searching for neighbors
[2021-03-05 07:56:31,622: INFO/MainProcess] mingle: all alone
[2021-03-05 07:56:31,647: INFO/MainProcess] celery@f9ab48fc6b63 ready.
这就是我将应用程序/生产者连接到代理的方式。
# celery_tasks.py
# imports...
app = Celery('celery_statst_api')
app.config_from_object(celeryconfig) # import config file
@app.task(name="foo")
def foo(first_arg: str) -> str:
print(f"thanks for {first_arg}")
return "OK"
最佳答案
问题出在我的配置文件中。 Celery 没有找到属性 broker_url
并且没有给出任何警告。相反, celery 默默地设置了一个默认值 amqp://guest:**@localhost:5672//
.在此处查看详细信息 https://github.com/celery/celery/issues/6661
关于python - celery 任务没有发送给经纪人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66462079/
我需要有关使用并发的 Java 作业的帮助。我遇到的问题是在 get 方法上,我找不到任何问题。然而,感觉它没有被正确访问,或者它没有做它应该做的事情。总而言之,问题是我得到了所有金属,但我没有给消费
有人可以为我定义提供者、服务和代理之间的概念区别吗? 我经常编写 MVC 应用程序并将大部分业务逻辑卸载到其他类。没什么特别的,只需传入参数并接收回 POCO 实例。 为那些为我的 Controlle
我有以下结构: zookeeper: 3.4.12 kafka: kafka_2.11-1.1.0 server1: zookeeper + kafka server2: zookeeper + ka
我收到 Message size too large异常(exception),当我尝试发送超过 1 Mb 大小的消息时。当我尝试生成消息时,错误出现在我的客户端应用程序中。经过一番谷歌搜索后,我发现
我按以下方式使用此处找到的主管代码 ( https://github.com/zeromq/majordomo ): 我没有使用单个代理来处理请求和回复,而是启动两个代理,这样其中一个处理所有请求,另
我是一名优秀的程序员,十分优秀!