Pascal Jahan Elahi (Pawsey)
01/20/2025, 6:43 AMMarvin
01/20/2025, 6:44 AMpython
from prefect import get_client
from prefect.states import Cancelled
async def cancel_task_run(task_run_id):
async with get_client() as client:
await client.set_task_run_state(task_run_id, Cancelled())
You can explore more about task state management and the Prefect API in the task engine source code.
For more detailed guidance, you may need to refer to the official Prefect documentation or the Prefect GitHub repository.
If you have more specific requirements or encounter issues, feel free to ask!Pascal Jahan Elahi (Pawsey)
01/20/2025, 6:50 AMMarvin
01/20/2025, 6:50 AMpython
from prefect import get_client
from prefect.states import Cancelled
async def cancel_task_run(task_run_id):
async with get_client() as client:
await client.set_task_run_state(task_run_id, Cancelled())
This example assumes you have access to the task run ID. For further details, you may want to explore the Prefect 2.x documentation or check the Prefect GitHub repository.
If you have more specific requirements or encounter any issues, feel free to ask!