python flask服务器假死,Python的Flask服务器崩溃GET请求到特定的端点:

博主在使用Flask构建的API中遇到一个问题,当尝试GET请求一个特定端点时,收到错误。错误日志显示在uwsgi中,请求方法(REQUEST_METHOD)缺失。同时,nginx的错误日志指出上游连接在读取响应头时提前关闭。经过检查,发现是nginx配置文件中的socket指向错误。修复了nginx配置,将socket路径指向正确的文件后,问题得到解决。
摘要由CSDN通过智能技术生成

All,

I have an API with two endpoints built using Flask. I am using an nginx/uwsgi combo for serving and I am getting an odd error whenever I send a GET request to one of the end points. The other endpoint works just fine.

Here is the output from my uwsgi log from a get request

File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1646, in request_context

return RequestContext(self, environ)

File "/usr/local/lib/python2.7/dist-packages/flask/ctx.py", line 166, in __init__

self.url_adapter = app.create_url_adapter(self.request)

File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in create_url_adapter

server_name=self.config['SERVER_NAME'])

File "/usr/local/lib/python2.7/dist-packages/werkzeug/routing.py", line 1196, in bind_to_environ

environ['REQUEST_METHOD'], environ.get('PATH_INFO'),

KeyError: 'REQUEST_METHOD'

And, here is the output from the nginx error log from a get request

2013/12/26 15:22:16 [error] 833#0: *9 upstream prematurely closed connection while reading response header from upstream,

client: 71.71.53.31, server: scholarly,

request: "GET /citelet/ HTTP/1.1",

upstream: "uwsgi://unix:///tmp/citelet.sock:",

host: "162.243.219.38"

I apologize for the vagueness of this question. I've set up this server several times on the same hardware, with the same libraries, and had no issues before. The error is confusing and I'm not really sure where to start looking.

Thanks in advance!

解决方案

Stupid mistake. There was an error in my nginx config. It was pointing to a non-existent socket.

server {

listen 80;

server_name scholarly;

# crowdscholar endpoint

location /crowdscholar {

uwsgi_pass unix:///tmp/crowdscholar.sock;

include uwsgi_params;

# strip path before handing it to app

uwsgi_param SCRIPT_NAME /crowdscholar;

uwsgi_modifier1 30;

}

# citelet endpoint

location /citelet {

uwsgi_pass unix:///tmp/citelet.sock;

include uwsgi_params;

# strip path before handing it to app

uwsgi_param SCRIPT_NAME /citelet;

uwsgi_modifier1 30;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值