0

我在 Heroku 中有两个文件,例如“app.py”和“notify.py”。当我运行“app.py”时。在某些情况下,我想运行“notify.py”,所以我使用这个函数“subprocess.Popen”来调用“notify.py”。我希望进程“notify.py”可以循环运行,甚至主进程结束后。我怎样才能做到这一点?

顺便说一句,我得到这样的错误

/bin/sh: 1: ./notify.py: 权限被拒绝

我使用如下的一些方法

  1. child = subprocess.Popen(['./notify.py'], shell=True, cwd='/app', stdin=None, stdout=subprocess.PIPE)
  2. child = subprocess.call(['./notify.py'], shell=True, cwd='/app', stdin=None, stdout=subprocess.PIPE)

但一切都不起作用

我尝试另一个像这样我notify()在 app.py 中创建一个函数并更改如下代码

child = subprocess.Popen([notify(text)], shell=True)

这行得通。但它会运行“通知(文本)”然后打印“测试”并返回。请告诉我为什么以及如何解决这个问题。

if event.message.text[0:6] == 'push**':
    t = event.message.text
    text = t.split('**')
    child = subprocess.Popen(['./notify.py'], shell=True, cwd='/app', stdin=None, stdout=subprocess.PIPE)
    print('test')
    return 0


/bin/sh: 1: ./notify.py: Permission denied
4

0 回答 0