当我尝试使用eta选项安排芹菜任务时,不会按预期日期时间进行处理。
代码段:
process_time_utc = datetime.datetime.fromtimestamp(time.mktime(x.utctimetuple()))
process_request.apply_async(eta=process_time_utc,kwargs={'description':xxxx})
settings.py code snippet
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
CELERY_ENABLE_UTC = Flase
CELERY_ALWAYS_EAGER = False
CARROT_BACKEND = 'django'
BROKER_URL = 'amqp://user2:xxx@localhost:xx56//'
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = ()
# ('Your Name', 'your_email@example.com'),
CELERY_IMPORT = 'xxx.app.tasks'
MANAGERS = ADMINS
DATABASES = {'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/test_data/test.db',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}}
TIME_ZONE = 'UTC'
这是芹菜输出日志,
[2014-07-07 20:04:08,407: INFO/MainProcess]
Got task from broker: xx.xxxx.app.tasks.process_request
[08029a2a-fdf0-4b50-b9a9-bdcf05ba71b5] eta:[2014-07-07 20:11:29+00:00]
[2014-07-07 20:04:48,785: INFO/MainProcess]
Got task from broker: xx.xxxx.app.tasks.process_request
[624c5592-8ed6-4f2c-93df-d48af584a074] eta:[2014-07-07 20:06:29+00:00]
注意: 我已经按照本教程http://celery.readthedocs.org/en/latest/reference/celery.app.task.html
进行了操作答案 0 :(得分:1)
Eta参数始终具有过去的日期时间。尝试添加一些延迟(秒,分钟,你需要的)或使用倒计时参数