class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):

    def handle(self):
        self.data = self.request.recv(1024).strip()
print('%s wrote: ' % self.client_address[0])
print(self.data)
self.request.send(self.data.upper())


class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
    pass
if __name__ == '__main__':
    pass
Python: Listen on two ports