1
我有Python Celery作为守护进程运行,Celerybeat在亚马逊Linux框上拾取任务。当我运行我的测试任务时,它没有发生任何事情就完成了。在运行Python Celery作为守护进程时无法执行Ruby脚本
@app.task
def test():
print("Testing 123")
return 0
然而,当我尝试使用Python的subprocess
模块,它轮询的时间屈指可数,以火了一个Ruby脚本,然后用1
返回代码退出。
@app.task
def run_cli():
try:
process = subprocess.Popen([filepath, "run"], stdout=subprocess.PIPE)
while not process.poll():
data = process.stdout.readline()
if data:
sys.stdout.write("Polling: " + data.decode("utf-8"))
else:
sys.stdout.write("Polling: No Data.")
return process.wait()
except Exception as e:
print(e)
我已经证实,当使用tasks.run_cli.apply()
在Python壳芹菜工人执行Ruby脚本顺利运行。那么,芹菜守护进程为什么不执行这个任务?
预警:我对Python非常陌生&芹菜和我的Linux技能很差,所以我很抱歉,如果它是明显的。任何帮助深表感谢。