V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
July7
V2EX  ›  Python

非常奇怪的问题,只能用 chrome 访问 python2 flask, curl 或 wget 访问超时

  •  
  •   July7 · 2018-06-29 01:08:07 +08:00 · 2613 次点击
    这是一个创建于 2099 天前的主题,其中的信息可能已经有所发展或是发生改变。
    阿里云的 Windows server 机器,装了 python2,运行 flask,用本地浏览器 Chrome 能访问一个地址如 http://localhost:8080/echo,顺利得到返回。
    用 curl 或者 wget 同样地址就卡在那里一直拿不到返回,直到超时。


    wget http://localhost:8080/echo
    --2018-06-28 10:58:31-- http://localhost:8080/echo
    Resolving localhost (localhost)... ::1, 127.0.0.1
    Connecting to localhost (localhost)|::1|:8080... failed: Connection refused.
    Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
    HTTP request sent, awaiting response...

    我是用 mingw 和 cygwin 实验都如此。用 java 程序 get 这个地址,仍然超时。
    5 条回复    2018-06-30 20:52:47 +08:00
    ca1123
        1
    ca1123  
       2018-06-29 02:03:34 +08:00
    IE 可以访问么?
    nicevar
        2
    nicevar  
       2018-06-29 10:42:12 +08:00
    这种问题抓个包看一下过程就知道了,靠猜解决不了问题
    lalalakakaka
        3
    lalalakakaka  
       2018-06-29 12:17:25 +08:00
    你是不是用了 python 自带的 webserver 模块?那个模块并发性能就是个残疾,会自己把自己卡死。
    建议换成 gevent 试试
    houzhiqiang
        4
    houzhiqiang  
       2018-06-29 15:32:24 +08:00
    部署的时候使用 gunicorn + gevent (或者看看 gunicorn 的各种工作模式),开发可以开启 flask 的多线程或者多进程,
    app.run(host='127.0.0.1', port='5000', debug=True, threaded=True)
    wushaojun321
        5
    wushaojun321  
       2018-06-30 20:52:47 +08:00 via iPhone
    单线程跑只能有一个客户访问吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3024 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 14:40 · PVG 22:40 · LAX 07:40 · JFK 10:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.