Piedon celery - how to add CELERYBEAT_SCHEDULE task at runtime for worker?

I created a celery worker with one task on a celerybeat schedule that runs at intervals of 5 seconds. I am wondering how I can add another beating task dynamically to a celery worker without stopping him.

Example

app.conf.update(
   CELERY_TASK_RESULT_EXPIRES=3600,
   CELERY_TIMEZONE = 'UTC',
   CELERYBEAT_SCHEDULE = {
    'long-run-5-secs': {
        'task': 'test_proj.tasks.test',
        'schedule': timedelta(seconds=5),
        'args': (16, )
    }
   }
)

With the above configuration, I can successfully start the celery worker with rhythm.

Now I need to add a dynamic schedule below dynamically

'long-run-2-secs': {'task': 'test_proj.tasks.test', "schedule": timedelta (seconds = 2), 'args': (14,)},

Need help with this

thanks

+4

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


All Articles