I have implmented a TCP to HTTP proxy server using urllib,
which converts a TCP request to a HTTP request to a specific server,
It's something like this:
class RequestHandler(socketserver.BaseRequestHandler):
    def handle(self):
        size, = struct.unpack('L', s.recv(4))
        data = s.recv(size)
        assert len(data) == size
        res = urllib.urlopen('http://myserver.com/', encode_data(data)).read()
        s.sendall(res)
        s.shutdown(SHUT_WR)
if __name__ == '__main__':
    address = ('', 8080)
    server = socketserver.ThreadingTCPServer(address, RequestHandler)
    server.serve_forever()        
But it became very slow on many connections(not too many: about 20) at the same time.
Where is the bottleneck? Is it related with GIL issue?
BTW: I'm on Windows so ForkingMixin is not available here
 
    