芹菜:工人在“broker_heartbeat”秒后收到第一个任务

Environment: - Vagrant (1.9.1) Ubuntu 14.04: - Docker (version 1.12.5): - RabbitMQ v3.6.5 - Client (Celery app v4.0.2, Python 2.7) - Server (Celery app v4.0.2, Python 3.5) 

用例:functiontesting。

 Workflow #1: 1. py.test (TestApp) starts in docker RabbitMQ and Server application. 2. TestApp registers "new" Client by sending task to Server. 3. TestApp starts in docker Client application. 4. Client and Server do a "handshake" by own protocol. 5. TestApp sends task to Client for test purposes (TestTask). 6. Client receives task immediately and executes it. Workflow #2: 1. py.test (TestApp) starts in docker RabbitMQ and Server application. 2. TestApp registers "active" Client by sending task to Server. 3. TestApp starts in docker Client application. 4. TestApp sends task to Client for test purposes (TestTask). 6. Client receives task after 60 seconds (THIS IS A PROBLEM). Workflow #2: 1. py.test (TestApp) starts in docker RabbitMQ and Server application. 2. TestApp registers "active" Client by sending task to Server. 3. TestApp starts in docker Client application. 4. TestApp sleeps for 20 seconds. 5. TestApp sends task to Client for test purposes (TestTask). 6. Client receives task immediately and executes it. 

我所研究的:

当Celery应用与RabbitMQbuild立连接时,他们协商一个60秒钟的心跳超时间隔,并在客户端的Celeryconfiguration中设置该值。

在工作stream#2中debuggingCelery的“内部”,我发现,只有在RabbiMQ发送Heartbeat到这个连接(我的configuration为60秒)之后,“epoll”才返回“准备好读取”状态的RabbitMQ连接套接字。

从工作stream程#1和#3我们可以看到,如果客户端启动和发送TestTask(握手和合成延迟)之间有一点点延迟,那么一切正常。

我对这种行为没有任何想法。 我需要尽快执行任务,而不是经过这么大的延迟。

我可以通过减less心跳超时间隔来修复testing,但这不是生产的选项。

你能提出什么build议?