我如何在Heroku中运行另一个进程

时间:2019-08-22 05:18:09

标签: python-3.x popen

我在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)

但所有方法都不起作用

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

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

它起作用。 但是它将运行“ notify(text)”,然后打印“ test”并返回。 请告诉我为什么以及如何解决这个问题。

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

0 个答案:

没有答案
相关问题