Running post tasks even if the main task fail
まだ誰も着手していません。
評価
調査の方向性
Start by tracing how pre and post tasks are executed around main_task and how unhandled exceptions propagate. Define the failure-path behavior so my_post_task performs cleanup after main_task fails, then verify both successful and failing task runs.
索引モデルが issue の本文から書いたものです。
説明
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()
def my_pre_task(ctx):
# Do some resource provisioning needed by the task
@task()
def my_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])
def main_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.
- 主要言語
- Python
- スター
- 4.8k
- フォーク
- 412
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pyinvoke/invoke のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
pyinvoke/invoke の issue をすべて見る
似ている issue
-
sponsored
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
Diaoul/subliminal#1382 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
triage/confirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
agentscope-ai/agentscope#2775 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100