Python - BaseHTTPServer.HTTPServer并发和线程

Ian*_*Ian 13 python multithreading basehttpserver httpserver socketserver

有没有办法使BaseHTTPServer.HTTPServer像SocketServer.ThreadingTCPServer一样多线程?

Wol*_*lph 19

你可以简单地使用线程mixin使用这两个类来使它成为多线程:)

虽然它对性能没什么帮助,但它至少是多线程的.

from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer

class MultiThreadedHTTPServer(ThreadingMixIn, HTTPServer):
    pass
Run Code Online (Sandbox Code Playgroud)

  • 这看起来像*a*解决方案..但是我宁愿选择编写自己的服务器而不是使用慢速的东西...... :( (2认同)