You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I was wondering if there's a way to make sure that a post task runs even if the main task fails with an unhandled exception? Here's a simplified version of my code to illustrate the issue:
@task()defmy_pre_task(ctx):
# Do some resource provisioning needed by the task@task()defmy_post_task(ctx):
# Perform resource cleanup# This should always run, but it won't if the main task fails with an unhandled exception@task(pre=[my_pre_task], post=[my_post_task])defmain_task(ctx):
# Do something that could also result in an unhandled exception
I know that I can wrap the main_task in a try/finally, but I'd rather not do this if I can find a more elegant solution. I was hoping there was something like post_run_on_failure=True that I could use, or a finally task that behaves like a post but always run.
The text was updated successfully, but these errors were encountered:
Hello. I was wondering if there's a way to make sure that a post task runs even if the main task fails with an unhandled exception? Here's a simplified version of my code to illustrate the issue:
I know that I can wrap the main_task in a try/finally, but I'd rather not do this if I can find a more elegant solution. I was hoping there was something like
post_run_on_failure=True
that I could use, or afinally
task that behaves like a post but always run.The text was updated successfully, but these errors were encountered: