Isaac Brodsky
11/11/2021, 9:01 PMIsaac Brodsky
11/11/2021, 9:02 PMKevin Kho
Isaac Brodsky
11/11/2021, 9:05 PMKevin Kho
Isaac Brodsky
11/11/2021, 9:13 PMKevin Kho
get_task_run_info
route. You can supply the task id from the context, but I think the window between cancellation request and the task shutting down is pretty small. Once the task shuts down, that code is not running so I don’t think it’s reliable to depend on that error you want to raise being raised.
Could you tell me more about what you’re trying to do?Isaac Brodsky
11/11/2021, 9:33 PM@task
def my_task_fn():
for i in range(SOME_LARGE_NUMBER):
# do work
if my_task_is_cancelled:
raise Error("I'm cancelled!")
Isaac Brodsky
11/11/2021, 9:33 PMIsaac Brodsky
11/11/2021, 9:34 PMKevin Kho
get_task_run_info
and pull the state and check if it is Cancelled
Isaac Brodsky
11/11/2021, 9:41 PMprefect.client.client.Client()
inside my task that was started by the Prefect agent it will get the auth information flowed through automatically?Kevin Kho
Isaac Brodsky
11/11/2021, 9:57 PM