Example #1
0
 def error_handler(data):
     """This function will be called in case of a fatal error in libgis"""
     # sys.stderr.write("Error handler was called\n")
     # We send an exception that will be handled in
     # the parent process, then close the pipe
     # and release any possible lock
     conn.send(FatalError("G_fatal_error() was called in the server process"))
     conn.close()
     lock.release()
Example #2
0
 def safe_receive(self, message):
     """Receive the data and throw a FatalError exception in case the server
        process was killed and the pipe was closed by the checker thread"""
     try:
         ret = self.client_conn.recv()
         if isinstance(ret,  FatalError):
            raise ret
         return ret
     except (EOFError,  IOError,  FatalError) as e:
         # The pipe was closed by the checker thread because
         # the server process was killed
         raise FatalError("Exception raised: " + str(e) + " Message: " + message)
Example #3
0
    def fatal(self, message):
        """Send an error message to stderr, call sys.exit(1) or raise FatalError

        :param message: the text of message
        :type message: str

           This function emulates the behavior of G_fatal_error(). It prints
           an error message to stderr and calls sys.exit(1). If raise_on_error
           is set True while creating the messenger object, a FatalError
           exception will be raised instead of calling sys.exit(1).
        """
        self._check_restart_server()
        self.client_conn.send(["ERROR", message])
        self.stop()

        if self.raise_on_error is True:
            raise FatalError(message)
        else:
            sys.exit(1)