search

Home  >  Q&A  >  body text

python - Celery 能让某个任务同时只能运行一个么。

有个任务在同一时间只能有一个进程执行它,假如这个任务celery 正在跑,后面再提交的就task忽略不跑了。
Celery有参数能快速设置么,还是要自己写逻辑控制。

高洛峰高洛峰2803 days ago935

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 09:52:48

    https://pypi.python.org/pypi/...

    There is a library called celery_once. The mechanism behind it is to set a task lock with the task name in redis. When a task is being executed, the same task cannot be triggered again.

    When a task is triggered, if it is found that the task already has a lock, an AlreadyQueued exception will be thrown, which is very suitable for use when the previous task has not been executed, the next cycle has arrived, and the mutual exclusion of scheduled tasks in the case of distributed task services scene.

    Hope it’s useful to you.

    reply
    0
  • Cancelreply