Celery 使用 Ansible API 结果 返回 None 无返回

方法1

# 在celery task 中 加入
# from multiprocessing import current_process
# current_process()._config={"semprefix":"/mp"}

@app.task
def create_task()
    from multiprocessing import current_process
    current_process()._config={"semprefix":"/mp"}
    # ...do something...
    return "hello world"
 
create_task.apply_async(
    ...
)

方法2

export PYTHONOPTIMIZE=1
再启动 supervisor celery
print(__debug__) # false is ok
posted @ 2023-07-06 14:15  snake_j  阅读(74)  评论(0)    收藏  举报