本文介绍了celery task eta已关闭,使用rabbitmq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用教程中的默认设置以及在ubuntu上运行的Rabbitmq,我已将Celery任务正常执行。当我毫不延迟地安排任务时,一切都很好,但是当我给他们一个eta时,它们就会在将来安排好,就像我的时钟不在某个地方一样。

I've gotten Celery tasks happening ok, using the default settings in the tutorials and rabbitmq running on ubuntu. All is fine when I schedule a task with no delay, but when I give them an eta, they get scheduled in the future as if my clock is off somewhere.

以下是一些要求执行任务的python代码:

Here is some python code that is asking for tasks:

for index, to_address in enumerate(email_addresses):
        # schedule one email every two seconds
        delay = index * 2
        log.info("MessageUsersFormView.process_action() scheduling task,"
            "email to %s, countdown = %i" % (to_address, delay) )
        tasks.send_email.apply_async(args=[to_address, subject, body],
            countdown = delay)

因此第一个应该立即熄灭,然后每两秒钟熄灭一次。看看我的芹菜控制台,第一个立即发生,然后其他两个间隔开两次,但明天开始:

So the first one should go out immediately, and then every two seconds. Looking at my celery console, the first one happens immediately, and then the others are scheduled two seconds apart, but starting tomorrow:

[2012-03-09 17:32:40,988: INFO/MainProcess] Got task from broker: stabil.tasks.send_email[24fafc0b-071b-490b-a808-29d47bbee435]
[2012-03-09 17:32:40,989: INFO/MainProcess] Got task from broker: stabil.tasks.send_email[3eb6c3ea-2c84-4368-babe-8a2ac0093836] eta:[2012-03-10 01:32:42.971072-08:00]
[2012-03-09 17:32:40,991: INFO/MainProcess] Got task from broker: stabil.tasks.send_email[a53110d6-b704-4d9c-904a-8d74b99a33af] eta:[2012-03-10 01:32:44.971779-08:00]
[2012-03-09 17:32:40,992: INFO/MainProcess] Got task from broker: stabil.tasks.send_email[2363329b-47e7-4edd-b38e-b09fed232003] eta:[2012-03-10 01:32:46.972422-08:00]

我俩都是新手Celery和RabbitMQ,因此有关如何解决此问题或在何处查找原因的任何技巧都将非常有用。这是在Ubuntu的VMWare虚拟机上,但是我的时钟设置正确。
谢谢!

I'm totally new to both Celery and RabbitMQ so any tips on how to fix this or where to look for the cause would be great. This is on a VMWare virtual machine of Ubuntu, but I have the clock set correctly.Thanks!

推荐答案

我认为它实际上按预期工作。左侧(方括号之间,以及INFO / MainProcess之前)的时间以 local 时间表示,但eta时间显示为 UTC 时间。例如:

I think it is actually working as you expect. The time on the left (between the square brackets and before INFO/MainProcess) is presented in local time, but the eta time is shown as UTC time. For instance:

采用控制台输出第二行中显示的预计到达时间:

Take the ETA time presented in the second line of your console output:

2012-03-10 01:32:42.971072-08:00

减去8小时( -08:00 是时区偏移量),您将得到:

Subtract 8 hours (-08:00 is the timezone offset) and you get:

2012-03-09 17:32:42.971072

发送后仅2秒时间:

2012-03-09 17:32:40,989

我希望这是有道理的。与时间打交道常常让我头疼。

I hope that makes sense. Dealing with times often gives me a headache.

这篇关于celery task eta已关闭,使用rabbitmq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:46