def __main_loop(self):
        """The main program loop, reads JSON requests from stdin,
        writes JSON responses to stdout

        """
        while(True):
            # reset result and log
            self.result = False
            self.log = []

            # get the request string, strip the ending "\n"
            self.__request  = self.__reader.readline().rstrip()

            # store the start time
            self._start_time = time.time()

            # when pdns is exiting it sends an empty line
            if self.__request == '':
                return

            # deserialize input
            try:
                obj = json.loads(self.__request)
            except ValueError:
                self.log.append('error: cannot parse input "{}"'
                                .format(self.__request))
                self.__write_response()
                return

            # get method name
            method_name = 'do_{}'.format(obj['method'])

            try:
                # get method
                method = getattr(self, method_name)
            except __HOLE__:
                self.result = False
                self.log.append('warning: method "{}" is not implemented'
                                .format(method_name, self.__request))
                self.__write_response()
                continue

            # DEBUG ONLY
            #method(obj['parameters'])
            #self.__write_response()
            #continue
            
            # execute method
            try:
                method(obj['parameters'])      
            except Exception:
                self.result = False
                self.log.append('error: method "{}" failed to execute'
                                .format(method_name, self.__request))
                self.__write_response()
                continue
            
            # write response
            self.__write_response()
dataset/ETHPy150Open polaris-gslb/polaris-gslb/polaris_pdns/core/remotebackend.py/RemoteBackend.__main_loop