Python TCPServer
Question: I have a simple question.

When I create a python TCPServer for example using the example code :

    
    
    import sys, SocketServer, os
    from multiprocessing import Pool, Queue
    
    class MyTCPHandler(SocketServer.BaseRequestHandler):
        def handle(self):
                    # self.request is the TCP socket connected to the client
                    self.data = self.request.recv(1024).strip()
                    print "{} wrote:".format(self.client_address[0])
                    print self.data
                    # just send back the same data, but upper-cased
                    self.request.sendall(self.data.upper())
    
    
    if __name__ == '__main__':
    
        pool = Pool(processes=2)
    
        HOST, PORT = "localhost", 9999
        server = SocketServer.TCPServer((HOST,PORT), MyTCPHandler )
        server.serve_forever()
    

My question is : How can i pass to the function handle on the Class
MyTCPHandler the Object Pool ?

Thanks


Answer: If you want to have a multithreading `TCPServer` you can use the
`ThreadingMixIn` mixin class like this:

    
    
    import SocketServer
    
    class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
        pass
    

You can also have a fork based TCPServer by using `ForkingMixIn` in the same
way as before.

More info can be found in the
[doc](http://docs.python.org/library/socketserver.html#asynchronous-mixins).

