推荐学习书目
› 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 · Jun 29, 2018 · 3840 views
    This topic created in 3018 days ago, the information mentioned may be changed or developed.
    阿里云的 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 replies  •  2018-06-30 20:52:47 +08:00
    ca1123
        1
    ca1123  
       Jun 29, 2018
    IE 可以访问么?
    nicevar
        2
    nicevar  
       Jun 29, 2018
    这种问题抓个包看一下过程就知道了,靠猜解决不了问题
    lalalakakaka
        3
    lalalakakaka  
       Jun 29, 2018
    你是不是用了 python 自带的 webserver 模块?那个模块并发性能就是个残疾,会自己把自己卡死。
    建议换成 gevent 试试
    houzhiqiang
        4
    houzhiqiang  
       Jun 29, 2018
    部署的时候使用 gunicorn + gevent (或者看看 gunicorn 的各种工作模式),开发可以开启 flask 的多线程或者多进程,
    app.run(host='127.0.0.1', port='5000', debug=True, threaded=True)
    wushaojun321
        5
    wushaojun321  
       Jun 30, 2018 via iPhone
    单线程跑只能有一个客户访问吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2236 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:37 · PVG 12:37 · LAX 21:37 · JFK 00:37
    ♥ Do have faith in what you're doing.