V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Get Google Chrome
Vimium · 在 Chrome 里使用 vim 快捷键
brucecobb
V2EX  ›  Chrome

Python BaseHTTPServer 模块

  •  
  •   brucecobb · 2019-07-21 11:47:53 +08:00 · 2558 次点击
    这是一个创建于 1733 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我是用 BaseHTTPServer 模块创建了个简单的 HTTP 服务,使用 chrome,firefox,postman 来进行测试,我发现只要 chrome 访问了这个 http 服务,firefox 和 postman 就无法访问了,但是反之 firefox 和 postman 访问后 chrome 还是可以访问,但是一旦 chrome 访问后,其他的就都不能访问了,显示服务器没有响应,经过我的测试,我发现再 chrome 的设置中关闭

    “预加载网页,以便实现更快速的浏览和搜索 使用 Cookie 记住您的偏好设置(即使您不访问这些网页)”这个这是就完全正常了,这是怎么回事呢?怎样再服务端解决此问题?

    6 条回复    2019-07-21 18:31:30 +08:00
    zjb861107
        1
    zjb861107  
       2019-07-21 11:54:13 +08:00
    好像是不支持并发,然后开了那个选项,Chrome 一直维持着连接
    lynskylate
        2
    lynskylate  
       2019-07-21 12:09:20 +08:00 via Android
    这个模块是单线程的...
    wwqgtxx
        3
    wwqgtxx  
       2019-07-21 12:37:31 +08:00 via iPhone
    有一个 threading 选项的
    pastgift
        4
    pastgift  
       2019-07-21 13:23:03 +08:00 via iPhone
    应该是 KeepAlive 把线程占了,BaseHTTPServer 默认单线程,可以开多线程模式的
    punderson
        5
    punderson  
       2019-07-21 16:07:18 +08:00
    你要开启多线程,每个请求开启个线程就好了。我之前写过一个类似的,https://gist.github.com/songouyang/22a811714f863b842c4de4c3da7ab03f
    brucecobb
        6
    brucecobb  
    OP
       2019-07-21 18:31:30 +08:00
    嗯嗯,谢谢大家,已经开启多线程。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5334 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:55 · PVG 16:55 · LAX 01:55 · JFK 04:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.