我的问题是
我使用django-celeron发布了两个倒计时任务,它必须在2014-10-15 06:45
和2014-10-15 08:45
上运行。
这是我使用--loglevel=INFO
运行时的日志
[2014-10-15 03:58:19,885: WARNING/MainProcess] celery@web468.webfaction.com ready.
[2014-10-15 05:57:08,777: INFO/MainProcess] Received task: mysite.celery.send_session_emails[e34174e2-543d-43aa-a7b0-a32b8be81644] eta:[2014-10-15 06:45:53.701697-04:00]
[2014-10-15 05:57:08,778: INFO/MainProcess] Received task: mysite.celery.send_session_emails[08c7935f-7546-428c-a8c5-1e25e0675b12] eta:[2014-10-15 08:45:53.745062-04:00]
[2014-10-15 06:45:54,704: INFO/MainProcess] Task mysite.celery.send_session_emails[e34174e2-543d-43aa-a7b0-a32b8be81644] succeeded in 0.683478601277s: None
<-- Great the task at 6:45 executed correctly...
[2014-10-15 06:58:09,522: INFO/MainProcess] Received task: mysite.celery.send_session_emails[08c7935f-7546-428c-a8c5-1e25e0675b12] eta:[2014-10-15 08:45:53.745062-04:00]
[2014-10-15 07:58:09,711: INFO/MainProcess] Received task: mysite.celery.send_session_emails[08c7935f-7546-428c-a8c5-1e25e0675b12] eta:[2014-10-15 08:45:53.745062-04:00]
<-- who published there two tasks,, i checked my code and i am sure that i didn't published them
[2014-10-15 08:45:55,469: INFO/MainProcess] Task mysite.celery.send_session_emails[08c7935f-7546-428c-a8c5-1e25e0675b12] succeeded in 0.410996085964s: None
[2014-10-15 08:45:55,815: INFO/MainProcess] Task mysite.celery.send_session_emails[08c7935f-7546-428c-a8c5-1e25e0675b12] succeeded in 0.345424972009s: None
[2014-10-15 08:45:56,292: INFO/MainProcess] Task mysite.celery.send_session_emails[08c7935f-7546-428c-a8c5-1e25e0675b12] succeeded in 0.47599364398s: None
<-- executed 3 tasks at 8:45, i actually published one at 8:45.
我的问题是why did celery automatically published those two tasks? ie
[2014-10-15 06:58:09,522: INFO/MainProcess] Received task: mysite......
[2014-10-15 07:58:09,711: INFO/MainProcess] Received task: mysite........
为了避免这个问题,我把我的芹菜经纪人换成了
SQLalchemy
。它解决了ETA任务的多次执行错误。
SQLAlchemy安装者:
pip install SQLAlchemy
更新了设置。py:
BROKER_URL='sqla+mysql://<mysql user>:<mysql password>@localhost/<mysql db_name>'