简体   繁体   中英

Celery scheduled task eta(apply_async(eta=xxx:23) option is not working

When I try to schedule the celery task using eta option, is not processing as expected date time.

Code Snippet:

 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'

Here is the celery output log,

[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]

Note: I have followed this tutorial http://celery.readthedocs.org/en/latest/reference/celery.app.task.html

Eta parameter always has a past datetime. Try to add some delay (seconds, minutes, what you need) or use the countdown parameter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM