Pascal Jahan Elahi (Pawsey)
01/20/2025, 7:00 AMmy_task.submit()
?Marvin
01/20/2025, 7:00 AMPrefectFuture
object obtained from my_task.submit()
, you can utilize the cancel()
method on the PrefectFuture
itself. This method allows you to request cancellation of the task, but note that the actual cancellation depends on whether the task runner supports it and the current state of the task.
Here’s a concise example:
python
from prefect import task, flow
@task
def my_task():
# Task logic here
pass
@flow
def my_flow():
future = my_task.submit()
# Cancel the task
future.cancel()
if __name__ == "__main__":
my_flow()
For more detailed information about task runners and futures, you can refer to the Prefect Task Runners documentation.
If you have further questions about the specific behavior of task cancellation, feel free to ask.