Celery expires option not working

I play with Celery and I am trying to do a periodic task with CELERYBEAT_SCHEDULER . Here is my configuration:

 CELERY_TIMEZONE = 'Europe/Kiev' CELERYBEAT_SCHEDULE = { 'run-task-every-5-seconds': { 'task': 'tasks.run_every_five_seconds', 'schedule': timedelta(seconds=5), 'options': { 'expires': 10, } }, } # the task @app.task() def run_every_five_seconds(): return '5 seconds passed' 

When you start the beat with celery -A celery_app beat task does not expire. Then I read that there might be some kind of bit problem, so it does not account for the expires option.

Then I tried to complete the task, so it is called manually.

 @app.task() def print_hello(): while True: print datetime.datetime.now() sleep(1) 

I call the task as follows:

 print_hello.apply_async(args=[], expires=5) 

The work console tells me that my task will expire, but it also has not expired. It runs endlessly.

 Received task: tasks.print_hello[05ee0175-cf3a-492b-9601-1450eaaf8ef7] expires:[2016-01-15 00:08:03.707062+02:00] 

Is there something I'm doing wrong?

+5
source share

Source: https://habr.com/ru/post/1240648/


All Articles