celery celerybeat可以在运行时动态添加/删除任务吗? [英] Can celery celerybeat dynamically add/remove tasks in runtime?

查看:359
本文介绍了celery celerybeat可以在运行时动态添加/删除任务吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不包含Django的项目,所以我不能使用djcelery。

I have a project that does not include Django, so i can't use djcelery.

但是我发现了修改 nofollow>使用sqlalchemy的django-celery
DatabaseSchedule 。

But i found the modification of django-celery DatabaseSchedule that using sqlalchemy.

它的工作原理就像djceley的DatabaseScheule一样。
但是唯一的问题是它似乎不发送在运行时添加的任务,然后我重新启动celery-beat,之前添加的任务将成功发送。

It works fine as like djceley's DatabaseScheule did. But the only problem is that it doesn't seem to send tasks that were added in runtime, then i restart the celery-beat, the tasks that were added before will be sent successfully.

因此,可以在不重新启动celery-beat的情况下动态添加/删除任务吗?

So, is it possible to dynamically add/remove tasks without restarting celery-beat?

谢谢您的任何建议。对不起,我的英语不好。

Thanks for any advice. And sorry for my bad english.

对不起,这是我的错。在运行时添加的任务将不会立即执行,您可以将 DatabaseScheduler.sync_every 值更改为更快的值。因此,它在等待几分钟后即可工作。

Sorry, it was my fault. The tasks that were added in runtime will not be picked up instantly, you can change the DatabaseScheduler.sync_every value to a faster one. So it works after waiting for several minutes.

感谢tuomur的帮助。

Thanks for tuomur's help.

推荐答案

解决方案1 :

我也遇到了同样的问题,问题是,芹菜定期计划程序将查找 [djcelery_periodictasks] ,其值为 [last_update] 。如果 [last_update] 没有变化,则芹菜将不会检查 [djcelery_periodictask] 表。

I too had the same problem, The problem is, Celery periodic scheduler will look for [djcelery_periodictasks] which will have [last_update] value. If there is no change in the [last_update] then the celery will not check the [djcelery_periodictask] table.

我们要做的是,每当您添加/删除任务时,更新 [last_update] 时间 [djcelery_periodictasks]

What we have to do is, When ever you add/remove a task update the [last_update] time in [djcelery_periodictasks].

在我的senario中,我在python中有定期的调度程序。但是我的Web UI用C#编写。我的Web应用程序将在 [djcelery_periodictask] 中添加/删除条目,并在<$ c中更新 [last_update] 时间$ c> [djcelery_periodictasks] 。

In my senario, I have the periodic scheduelr in python. However my Web UI is written in C#. my web application will add/remove the entry in [djcelery_periodictask] and update the [last_update] time in [djcelery_periodictasks].

通过这种方式,我已经解决了这个问题。

By this way, i have solved this issue.

当我们使用标准的 flower UI时,如果添加/删除任务,它将更新 [last_update] 时间在 [djcelery_periodictasks] 中。如果您已经开发了自己的自定义UI /应用程序,则必须包含在 [djcelery_periodictasks] [last_update] 时间的功能。 c>动态添加/删除任务。

When we use the standard flower UI, If we add/remove the task it will update the [last_update] time in [djcelery_periodictasks]. IF you have developed your own custom UI / application you have to include the functionality to update [last_update] time in [djcelery_periodictasks] to dynamically add/remove the task.

解决方案2:

使用flower: https://github.com/mher/flower

这篇关于celery celerybeat可以在运行时动态添加/删除任务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆