Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt

Use this file to discover all available pages before exploring further.

Tasks.astop cancels a running task. The platform marks it Stopped, signals the worker to abandon its current step, and returns the updated record.
from xpander_sdk import Tasks

tasks = Tasks()
stopped = await tasks.astop(task_id="task_xyz")
print(stopped.status.value, stopped.is_manually_stopped)   # "stopped" True

Parameters

ParameterTypeRequiredDescription
task_idstrYesTask to stop.

Returns Task

The task record after the stop request was processed. status is Stopped, is_manually_stopped is True, and finished_at is set.

Examples

Stop from a running Task instance

If you already have the Task object, prefer the instance method:
await task.astop()
print(task.status.value)   # "stopped"
Task.astop() and Tasks().astop(task_id=task.id) are equivalent: the instance method also updates the in-memory object.

Idempotent stop

Calling astop on an already-terminal task is safe: the platform returns the existing record without changing state.
# First call: stops it
await tasks.astop(task_id="task_xyz")

# Second call: no-op, returns the same record
await tasks.astop(task_id="task_xyz")

Sync version

tasks.stop(task_id="task_xyz")

Errors

Raises ModuleException. Common statuses:
StatusCause
404Task doesn’t exist.
500Server error.