Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t在运行Python芹菜作为守护进程时执行Ruby脚本_Ruby_Linux_Celery_Daemon_Python 3.5 - Fatal编程技术网

Can';t在运行Python芹菜作为守护进程时执行Ruby脚本

Can';t在运行Python芹菜作为守护进程时执行Ruby脚本,ruby,linux,celery,daemon,python-3.5,Ruby,Linux,Celery,Daemon,Python 3.5,我让Python芹菜作为守护进程运行,Celerybeat在Amazon Linux机器上接收任务。当我运行测试任务时,它会顺利完成 @app.task def test(): print("Testing 123") return 0 但是,当我尝试使用Python的子流程模块启动Ruby脚本时,它会轮询几次,然后返回代码1 @app.task def run_cli(): try: process = subprocess.Popen([filepa

我让Python芹菜作为守护进程运行,Celerybeat在Amazon Linux机器上接收任务。当我运行测试任务时,它会顺利完成

@app.task
def test():
    print("Testing 123")
    return 0
但是,当我尝试使用Python的
子流程
模块启动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)
我已经确认,Ruby脚本在Python shell中由芹菜工人使用
tasks.run_cli.apply()
执行时运行良好。那么为什么芹菜守护进程不执行这个任务呢


预先警告:我对Python和芹菜还很陌生,我的Linux技能参差不齐,所以如果这是显而易见的,我道歉。非常感谢您的帮助。

对于结束Ruby脚本的轮询,必须将非零信号发送回Python脚本,否则进程将完成,Python将继续轮询而不接收数据。在else条件下也可能中断循环,因为对
process.stdout.readline()
的错误响应表明(我怀疑)脚本处理已完成