相关疑难解决方法(0)

什么是文件描述符,用简单的术语解释?

  1. 与维基百科相比,文件描述符的简化描述是什么?他们为什么需要?比如说,以shell进程为例,它是如何应用的?

  2. 进程表是否包含多个文件描述符.如果是,为什么?

unix operating-system file-descriptor

351
推荐指数
12
解决办法
19万
查看次数

Gunicorn + nginx - 忽略 EPIPE

我在谷歌计算上运行了一个 nginx-gunicorn-flask 设置,我不断从 gunicorn 获得以下信息:

[2019-04-19 20:50:49 +0000] [3345] [DEBUG] POST /
[2019-04-19 20:50:49 +0000] [3345] [DEBUG] Ignoring EPIPE
Run Code Online (Sandbox Code Playgroud)

在 100 个请求中,大约有 23 个是这样出现的。在访问日志中只显示了 23 个请求,它们都是 200 个。

从 nginx 访问日志显示 504,在错误日志中我看到:

2019/04/19 20:50:49 [error] 3097#3097: *295 upstream timed out (110: Connection timed out) while sending request to upstream, client: ip, server: , request: "POST / HTTP/1.1", upstream: "http://unix:/home/user/Server/server.sock/", host: "ip"

Run Code Online (Sandbox Code Playgroud)

我试过设置

proxy_connect_timeout 75s;
proxy_read_timeout 300s;
Run Code Online (Sandbox Code Playgroud)

--timeout 300根据其他问题在 nginx 和gunicorn上的位置,但没有帮助。

来自 gunicorn 的消息并没有真正帮助确定原因,我没有找到任何相关信息

一直试图解决这个问题,我很感激任何想法。此外,这些请求中的每一个都需要大约 1-2 秒,并且 jmeter …

python nginx gunicorn server ubuntu-18.04

11
推荐指数
2
解决办法
2926
查看次数

'yes'与子进程通信报告错误()

我使用以下函数在Python中运行命令:

def run_proc(cmd):
    child = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout, stderr = child.communicate()
    returncode = child.returncode
    return stdout, stderr, returncode
Run Code Online (Sandbox Code Playgroud)

它一直工作正常,但现在我正在尝试使用该yes程序将输出管道输出到stdin.我正在尝试运行的命令如下:

yes '' | apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
Run Code Online (Sandbox Code Playgroud)

但我相信它可以用一般的例子代替,例如:

yes | head -3 | cat
Run Code Online (Sandbox Code Playgroud)

我的问题是,如果我尝试运行其中的任何命令yes |,上面的subprocess.Popen将包含错误消息:

yes: standard output: Broken pipe
yes: write error
Run Code Online (Sandbox Code Playgroud)

对我来说,似乎管道仍然可以工作,从yes | head -3 | cat答案中可以看出:y y y.

我有以下问题:

  1. 是的管道是否仍然可用,即使是报告错误?
  2. 我该如何解决?

python linux shell command-line subprocess

4
推荐指数
1
解决办法
2015
查看次数