From a8e5c0141c0a9da51edf443c21cd704d4bac9c31 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Fri, 20 Jun 2025 12:19:27 +0200 Subject: [PATCH 1/2] Update infrequent polling sample to use BENIGN application error --- polling/test_service.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/polling/test_service.py b/polling/test_service.py index 490f8476..e393d2e6 100644 --- a/polling/test_service.py +++ b/polling/test_service.py @@ -2,6 +2,7 @@ from typing import Counter from temporalio import activity +from temporalio.exceptions import ApplicationError, ApplicationErrorCategory attempts = Counter[str]() ERROR_ATTEMPTS = 5 @@ -20,4 +21,10 @@ async def get_service_result(input): print(f"Attempt {attempts[workflow_id]} of {ERROR_ATTEMPTS} to invoke service") if attempts[workflow_id] == ERROR_ATTEMPTS: return f"{input.greeting}, {input.name}!" - raise Exception("service is down") + raise ApplicationError( + message="service is down", + # Set the error as BENIGN to indicate it is an expected error. + # BENIGN errors have activity failure logs downgraded to DEBUG level + # and do not emit activity failure metrics. + category=ApplicationErrorCategory.BENIGN + ) From 4b431702d8bd0cdc580c0b862d4a75e75d011fcd Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Fri, 20 Jun 2025 14:28:52 +0200 Subject: [PATCH 2/2] formatting/linting --- polling/test_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polling/test_service.py b/polling/test_service.py index e393d2e6..63494572 100644 --- a/polling/test_service.py +++ b/polling/test_service.py @@ -26,5 +26,5 @@ async def get_service_result(input): # Set the error as BENIGN to indicate it is an expected error. # BENIGN errors have activity failure logs downgraded to DEBUG level # and do not emit activity failure metrics. - category=ApplicationErrorCategory.BENIGN + category=ApplicationErrorCategory.BENIGN, )