使用Python修复uWSGI中的管道损坏错误

Jua*_*oto 14 python rest timeout wsgi uwsgi

my_resource在Python中命中REST资源()时,uWSGI服务器在其日志中抛出以下错误:

SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request my_resource (ip <my_ip>) !!!
uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 164]
IOError: write error
Run Code Online (Sandbox Code Playgroud)

它似乎与超时有关(客户端在请求完成处理之前断开连接).

这是什么类型的超时以及如何解决?

rob*_*rto 9

这取决于你的前端服务器.例如,nginx具有uwsgi_read_timeout参数.(通常设为60秒).uWSGI http路由器的--http-timeout默认为60秒,依此类推.当你在谈论休息时,我很怀疑它需要超过60秒来生成响应,你确定你没有一些错误的响应标头触发前端网络服务器连接关闭吗?


Chr*_*aes 5

如果您使用的是uwsginginx 插件,请考虑使用

uwsgi_connect_timeout 180;
uwsgi_read_timeout 180;
uwsgi_send_timeout 180;
Run Code Online (Sandbox Code Playgroud)

  • 在 nginx.conf 里面 (2认同)