def _get_execution_result(
        self, execution, action_exec_mgr, args, force_retry_on_finish=False, **kwargs
    ):
        """
        :param force_retry_on_finish: True to retry execution details on finish even if the
                                      execution which is passed to this method has already finished.
                                      This ensures we have latest state available for that
                                      execution.
        """
        pending_statuses = [
            LIVEACTION_STATUS_REQUESTED,
            LIVEACTION_STATUS_SCHEDULED,
            LIVEACTION_STATUS_RUNNING,
            LIVEACTION_STATUS_CANCELING,
        ]

        if args.tail:
            # Start tailing new execution
            print('Tailing execution "%s"' % (str(execution.id)))
            execution_manager = self.app.client.managers["Execution"]
            stream_manager = self.app.client.managers["Stream"]
            ActionExecutionTailCommand.tail_execution(
                execution=execution,
                execution_manager=execution_manager,
                stream_manager=stream_manager,
                **kwargs,
            )

            execution = action_exec_mgr.get_by_id(execution.id, **kwargs)
            print("")
            return execution

        poll_counter = 0

        if not args.action_async:
            while execution.status in pending_statuses:
                poll_counter += 1
                time.sleep(self.poll_interval)
                if not args.json and not args.yaml:
                    sys.stdout.write(".")
                    sys.stdout.flush()
                execution = action_exec_mgr.get_by_id(execution.id, **kwargs)

            sys.stdout.write("\n")

            if poll_counter == 0 and force_retry_on_finish:
                # In some situations we want to retrieve execution details from API even if it has
                # already finished before performing even a single poll. This ensures we have the
                # latest data for a particular execution.
                execution = action_exec_mgr.get_by_id(execution.id, **kwargs)

            if execution.status == LIVEACTION_STATUS_CANCELED:
                return execution

        return execution

        :param force_retry_on_finish: True to retry execution details on finish even if the
                                      execution which is passed to this method has already finished.
                                      This ensures we have latest state available for that
                                      execution.
        
st2client/st2client/commands/action.py