Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.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
即使在python2内部使用子进程,也无法触发带星号AGI的python 3代码_Python_Asterisk - Fatal编程技术网

即使在python2内部使用子进程,也无法触发带星号AGI的python 3代码

即使在python2内部使用子进程,也无法触发带星号AGI的python 3代码,python,asterisk,Python,Asterisk,我正在运行一个由拨号计划触发的python2代码。为了处理保存的录音,我需要运行python 3脚本。有办法吗。如果我将代码切换到python3,则代码不起作用。 这是分机 same=>n,AGI(code.py) 在code.py中指定标题时 #!/usr/bin/env蟒蛇2 我能够运行该函数 def run_cmd(cmd): #This runs the general command sys.stderr.write(cmd) sys.stderr.flush()

我正在运行一个由拨号计划触发的python2代码。为了处理保存的录音,我需要运行python 3脚本。有办法吗。如果我将代码切换到python3,则代码不起作用。 这是分机 same=>n,AGI(code.py)

在code.py中指定标题时 #!/usr/bin/env蟒蛇2

我能够运行该函数

def run_cmd(cmd):
#This runs the general command 
   sys.stderr.write(cmd)
   sys.stderr.flush()
   sys.stdout.write(cmd)
   sys.stdout.flush()
   result = sys.stdin.readline().strip()
   checkresult(result)
能够处理各种agi命令 但是在切换到Python3
#时/usr/bin/env python3
代码无法运行。 现在我需要使用谷歌云引擎来处理用python 3编写的东西

有办法让它运行吗 我已经做了

def run_sys_command(command):
   subprocess.call(command, shell=True)
   checkresult(result)
  
command = "sudo python3 /root/Downloads/check2.py"
run_sys_command(command)
是否有任何方法可以运行Python3脚本或直接使用agi运行Python3脚本


我已经检查了所有内容的权限

确保您可以在AGI中运行线程

但它应该在AGI脚本结束之前停止

做您想做的事情的最简单方法是设置某种类型的队列(mysql中的rabbitmq/simple tasks list?)并在asterisk进程范围之外处理它

作为AGI脚本运行python3没有任何问题。我的项目中有很多这样的脚本。检查一下你的代码