Paweł Biernat
12/19/2024, 9:10 AMMarvin
12/19/2024, 9:10 AMPrefectFuture
object provides access to the computation happening within a task runner, which allows you to interact with task executions. However, directly canceling a task future isn't standard practice through Prefect's API like you might do with a simple future in a Python concurrency library.
For Prefect 2.x and 3.x, you can use .result()
on a PrefectFuture
for various interactions like waiting for completion, but canceling via this object isn't highlighted in the documentation. Prefect's default operations rely on the flow and task settings you've defined, like retries or timeouts, to handle exceptional cases.
If you are looking to manage task cancellations, consider setting up your tasks and flows to handle exceptions robustly or to check and respect some form of cancellation signal within the task's execution logic.
For more detailed guidance, you can explore these resources:
- Prefect 2.x Task Runners: Prefect 2.x Documentation
- Prefect 3.x: Task Control: Prefect 3.x Documentation
Of course, the best task is a completed task, but sometimes even tasks need a snooze button!