[英]Cant trigger python 3 code with asterisk AGI even on using subprocess inside python2
我正在運行一個由撥號計划觸發的 python2 代碼。 為了處理保存的錄音,我需要運行 python 3 腳本。 有沒有辦法做到這一點。 如果我將代碼切換到 python3,則代碼不起作用。 這是擴展名 same=>n,AGI(code.py)
在 code.py 中給出 header #!/usr/bin/env python2
我能夠運行 function
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 命令,但將其切換到 python 3 #!/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)
有什么方法可以直接使用 agi 運行 python 3 腳本或任何方法來運行 python 3 腳本。
我已經檢查了所有內容的權限
當然,您可以在 AGI 中運行線程。
但它應該在 AGI 腳本結束之前停止。
做你想做的最簡單的方法 - 設置某種類型的隊列(mysql 中的rabbitmq /簡單任務列表?)並在星號進程scope之外處理它。
將 python3 作為 AGI 腳本運行沒有任何問題。 我的項目中有很多這樣的腳本。 只需檢查您的代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.