Is there a way to make BaseHTTPServer.HTTPServer be multi-threaded like SocketServer.ThreadingTCPServer?
+3
A:
You can simply use the threading mixin using both of those classes to make it multithread :)
It won't help you much in performance though, but it's atleast multithreaded.
class MultiThreadedHTTPServer(ThreadingMixin, HTTPServer):
pass
WoLpH
2010-03-07 22:36:52
This looks like *a* solution.. however I'd rather opt to write my own server than use something slow.. :(
Ian
2010-03-08 18:49:23
If you're simply looking for hosting Python than why not use an existing http server like nginx, apache or lighttpd?As for the performance, threading it will allow you to make multiple concurrent connections without blocking so in the case of multiple simultaneous requests it will be faster. But it will still use only 1 processor.
WoLpH
2010-03-09 00:16:15
I'm not looking for that, I'm making a Queue server that takes incoming requests (http or some similar format) and does an action based on the request.
Ian
2010-03-09 04:09:27
here is a reference: [link](http://www.doughellmann.com/PyMOTW/BaseHTTPServer/index.html#module-BaseHTTPServer), threading, forking
sfossen
2010-04-08 17:52:14
@Ian: since you're making a queue server you might want to try some other technology. Take a look at the eventlet library: http://wiki.secondlife.com/wiki/Eventlet
WoLpH
2010-04-08 22:53:27