简体   繁体   English

从任务中退出 Django Celery worker

[英]Quit Django Celery worker from within task

From within a celery task (ie a Python function) I wish to be able to shutdown the entire celery worker - how can I do this?在 celery 任务(即 Python 函数)中,我希望能够关闭整个 celery worker - 我该怎么做?

(Platform is Ubuntu.) (平台为Ubuntu。)

It's not very elegant, but this does the trick:它不是很优雅,但它可以解决问题:

import subprocess
subprocess.call("pkill -9 -f 'celery worker'", shell=True, executable="/bin/bash")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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