Skip to content

cancel_task async

cancel_task(
    task_id: TaskId,
    *,
    config_overrides: Optional[AsyncSnowDeviceManagementClientConfig] = None,
) -> CancelTaskOutput

Sends a cancel request for a specified task. You can cancel a task only if it's still in a QUEUED state. Tasks that are already running can't be cancelled.

A task might still run if it's processed from the queue before the CancelTask operation changes the task's state.

Parameters:

  • task_id (TaskId) –

    The ID of the task that you are attempting to cancel. You can retrieve a task ID by using the ListTasks operation.

Raises:

Source code in docs_src/capo_snow_device_management/_services/async_snow_device_management.py
async def cancel_task(
    self,
    task_id: "capo_snow_device_management.types.task_id.TaskId",
    *,
    config_overrides: Optional[AsyncSnowDeviceManagementClientConfig] = None,
) -> "capo_snow_device_management.types.cancel_task_output.CancelTaskOutput":
    """<p>Sends a cancel request for a specified task. You can cancel a task only if it's still in a <code>QUEUED</code> state. Tasks that are already running can't be cancelled.</p> <note> <p>A task might still run if it's processed from the queue before the <code>CancelTask</code> operation changes the task's state.</p> </note>

    Args:
        task_id: <p>The ID of the task that you are attempting to cancel. You can retrieve a task ID by using the <code>ListTasks</code> operation.</p>

    Raises:
        capo_snow_device_management.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_snow_device_management.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred while processing the request.</p>
        capo_snow_device_management.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resource that doesn't exist.</p>
        capo_snow_device_management.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_snow_device_management.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_snow_device_management.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_snow_device_management.types.cancel_task_input.CancelTaskInput]",
    ) -> AsyncOperationResponse[
        "capo_snow_device_management.types.cancel_task_output.CancelTaskOutput"
    ]:
        import capo_snow_device_management._operations.snow_device_management.cancel_task

        (
            output,
            http_response,
        ) = await capo_snow_device_management._operations.snow_device_management.cancel_task.async_cancel_task(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CancelTask")
    )
    input_: capo_snow_device_management.types.cancel_task_input.CancelTaskInput = {
        "task_id": task_id
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output