def _perform_action()

in amazon_kclpy/kcl.py [0:0]


    def _perform_action(self, action):
        """
        Maps input action to the appropriate method of the record processor.

        :type action:
        :param MessageDispatcher action: A derivative of MessageDispatcher that will handle the provided input

        :raises MalformedAction: Raised if the action is missing attributes.
        """

        try:
            action.dispatch(self.checkpointer, self.processor)
        except SystemExit as sys_exit:
            # On a system exit exception just go ahead and exit
            raise sys_exit
        except Exception as ex:
            """
            We don't know what the client's code could raise and we have no way to recover if we let it propagate
            up further. We will mimic the KCL and pass over client errors. We print their stack trace to STDERR to
            help them notice and debug this type of issue.
            """
            self.io_handler.error_file.write("Caught exception from action dispatch: {ex}".format(ex=str(ex)))
            traceback.print_exc(file=self.io_handler.error_file)
            self.io_handler.error_file.flush()