def TerminateTaskInstance(self, request):
        """This API is used to terminate a task instance.
        Task instances in the "SUCCEED" or "FAILED" state will not be processed.
        Task instances in the "SUBMITTED", "PENDING", or "RUNNABLE" state will be set to the "FAILED" state.
        For task instances in the "STARTING", "RUNNING", or "FAILED_INTERRUPTED" state, there will be two cases: if no compute environment is specified, the CVM instance will be terminated first, and then the state will be set to "FAILED"; if a compute environment's EnvId is specified, the state of the task instances will be set to "FAILED" first, and then the CVM instance that performs the task will be restarted. Both cases takes a certain amount of time to be completed.
        For task instances in the "FAILED_INTERRUPTED" state, the related resources and quotas will be released only after the termination actually succeeds.

        :param request: Request instance for TerminateTaskInstance.
        :type request: :class:`tencentcloud.batch.v20170312.models.TerminateTaskInstanceRequest`
        :rtype: :class:`tencentcloud.batch.v20170312.models.TerminateTaskInstanceResponse`

        """
        try:
            params = request._serialize()
            body = self.call("TerminateTaskInstance", params)
            response = json.loads(body)
            if "Error" not in response["Response"]:
                model = models.TerminateTaskInstanceResponse()
                model._deserialize(response["Response"])
                return model
            else:
                code = response["Response"]["Error"]["Code"]
                message = response["Response"]["Error"]["Message"]
                reqid = response["Response"]["RequestId"]
                raise TencentCloudSDKException(code, message, reqid)
        except Exception as e:
            if isinstance(e, TencentCloudSDKException):
                raise
            else:
                raise TencentCloudSDKException(e.message, e.message)
예제 #2
0
    def TerminateTaskInstance(self, request):
        """用于终止任务实例。
        对于状态已经为“SUCCEED”和“FAILED”的任务实例,不做处理。
        对于状态为“SUBMITTED”、“PENDING”、“RUNNABLE”的任务实例,状态将置为“FAILED”状态。
        对于状态为“STARTING”、“RUNNING”、“FAILED_INTERRUPTED”的任务实例,分区两种情况:如果未显示指定计算环境,会先销毁CVM服务器,然后将状态置为“FAILED”,具有一定耗时;如果指定了计算环境EnvId,任务实例状态置为“FAILED”,并重启执行该任务的CVM服务器,具有一定的耗时。
        对于状态为“FAILED_INTERRUPTED”的任务实例,终止操作实际成功之后,相关资源和配额才会释放。

        :param request: Request instance for TerminateTaskInstance.
        :type request: :class:`tencentcloud.batch.v20170312.models.TerminateTaskInstanceRequest`
        :rtype: :class:`tencentcloud.batch.v20170312.models.TerminateTaskInstanceResponse`

        """
        try:
            params = request._serialize()
            body = self.call("TerminateTaskInstance", params)
            response = json.loads(body)
            if "Error" not in response["Response"]:
                model = models.TerminateTaskInstanceResponse()
                model._deserialize(response["Response"])
                return model
            else:
                code = response["Response"]["Error"]["Code"]
                message = response["Response"]["Error"]["Message"]
                reqid = response["Response"]["RequestId"]
                raise TencentCloudSDKException(code, message, reqid)
        except Exception as e:
            if isinstance(e, TencentCloudSDKException):
                raise
            else:
                raise TencentCloudSDKException(e.message, e.message)
    def TerminateTaskInstance(self, request):
        """用于终止任务实例
        对于状态已经为SUCCEED、FAILED的TaskInstance,batch不做处理。
        对于状态为SUBMITTED、PENDING、RUNNABLE的TaskInstance,batch会将其置为FAILED状态。
        对于状态为STARTING、RUNNING、FAILED_INTERRUPTED的TaskInstance,batch会先终止CVM,然后将状态置为FAILED,因此具有一定耗时。特别是如果CVM正在创建中,此时无法立即销毁CVM,Batch会在旁路注册一个定时销毁操作,在CVM创建好之后异步销毁。
        对于状态为FAILED_INTERRUPTED的TaskInstance,TerminateTaskInstance操作实际成功之后,相关资源和配额才会释放。
        本接口只支持提交到匿名计算环境的作业(SubmitJob指定ComputeEnv,不指定EnvId)。对于提交到具名计算环境的作业(SubmitJob指定EnvId,不指定ComputeEnv),不支持TerminateTaskInstance和TerminateJob操作。

        :param request: 调用TerminateTaskInstance所需参数的结构体。
        :type request: :class:`tencentcloud.batch.v20170312.models.TerminateTaskInstanceRequest`
        :rtype: :class:`tencentcloud.batch.v20170312.models.TerminateTaskInstanceResponse`

        """
        try:
            params = request._serialize()
            body = self.call("TerminateTaskInstance", params)
            response = json.loads(body)
            if "Error" not in response["Response"]:
                model = models.TerminateTaskInstanceResponse()
                model._deserialize(response["Response"])
                return model
            else:
                code = response["Response"]["Error"]["Code"]
                message = response["Response"]["Error"]["Message"]
                reqid = response["Response"]["RequestId"]
                raise TencentCloudSDKException(code, message, reqid)
        except Exception as e:
            if isinstance(e, TencentCloudSDKException):
                raise e
            else:
                raise TencentCloudSDKException(e.message, e.message)