Running post tasks even if the main task fail
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 4.8k
- Fork
- 412
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pyinvoke/invoke
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
-
sdist is missing `pytest.ini` Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Tất cả issue của pyinvoke/invoke
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100