Multithreading support for BaseHTTPServer

Gerson Kurz gerson.kurz at t-online.de
Tue Aug 28 07:21:26 EDT 2001


I'm using a BaseHTTPServer to serve up data dynamically. Some pages
take time to process, so I would like to make a multithread server
where serving up one page doesn't block any other. 

Looking into SocketServer.py, I found that both ThreadingTCPServer and
ForkingTCPServer are available. However, when changing

class HTTPServer(SocketServer.TCPServer):

to 

class HTTPServer(SocketServer.ThreadingTCPServer):

in BaseHTTPServer, I get an error

  File "D:\Python21\Lib\BaseHTTPServer.py", line 262, in handle
    self.raw_requestline = self.rfile.readline()
  File "d:\python21\lib\socket.py", line 233, in readline
    new = self._sock.recv(self._rbufsize)
AttributeError: 'int' object has no attribute 'recv'

Any ideas? Any simple method of multithreading BaseHTTPServer? 



More information about the Python-list mailing list