我有一些代码使用子进程来查看 git 目录中的日志。在本地 django 开发环境中执行时,我的代码似乎工作正常。但是,一旦部署(使用 Apache / mode_wsgi),stdout read() 的输出就会返回空。我的开发和生产机器现在是一样的,我也尝试确保每个文件都是可读的。
有谁知道为什么 Popen 在这里部署后不返回任何输出?谢谢。
def getGitLogs(projectName, searchTerm=None, since):
os.chdir(os.path.join(settings.SCM_GIT, projectName))
cmd = "git log --since {0} -p".format(since)
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
output = p.stdout.read()
### here output comes back as expected in dev environment, but empty in once deployed
return filterCommits(parseCommits(output), searchTerm)