相关疑难解决方法(0)

芹菜:守护进程不允许有孩子

在Python(2.7)中,我尝试在芹菜任务(celery 3.1.17)中创建进程(使用多处理),但它给出了错误:

daemonic processes are not allowed to have children
Run Code Online (Sandbox Code Playgroud)

谷歌搜索它,我发现最新版本的台球修复了"错误",但我有最新版本(3.3.0.20),错误仍在发生.我也试图在我的芹菜任务中实现这个解决方法,但它给出了同样的错误.

有谁知道怎么做?任何帮助表示赞赏,帕特里克

编辑:代码片段

任务:

from __future__ import absolute_import
from celery import shared_task
from embedder.models import Embedder

@shared_task
def embedder_update_task(embedder_id):
    embedder = Embedder.objects.get(pk=embedder_id)
    embedder.test()
Run Code Online (Sandbox Code Playgroud)

人工测试功能(从这里):

def sleepawhile(t):
    print("Sleeping %i seconds..." % t)
    time.sleep(t)
    return t    

def work(num_procs):
    print("Creating %i (daemon) workers and jobs in child." % num_procs)
    pool = mp.Pool(num_procs)

    result = pool.map(sleepawhile,
        [randint(1, 5) for x in range(num_procs)])

    # The following is not really needed, …
Run Code Online (Sandbox Code Playgroud)

python daemon celery python-2.7 python-multiprocessing

12
推荐指数
3
解决办法
6929
查看次数