diff --git a/clients/python/src/taskbroker_client/worker/workerchild.py b/clients/python/src/taskbroker_client/worker/workerchild.py index d8f206e1..726b4722 100644 --- a/clients/python/src/taskbroker_client/worker/workerchild.py +++ b/clients/python/src/taskbroker_client/worker/workerchild.py @@ -30,7 +30,7 @@ TaskActivation, TaskActivationStatus, ) -from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS +from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.crons import MonitorStatus, capture_checkin from taskbroker_client.app import import_app @@ -658,30 +658,25 @@ def _execute_activation( if "__start_time" in kwargs: kwargs.pop("__start_time") - try: - with contextlib.ExitStack() as stack: - with metrics.timer( - "taskworker.worker.context_rebuild.duration", - tags={ - "namespace": activation.namespace, - "taskname": activation.taskname, - }, - ): - for hook in context_hooks: - stack.enter_context(hook.on_execute(headers)) - if task_func.pass_headers: - if "headers" in kwargs: - raise TypeError( - f"Task '{task_func.name}' has pass_headers=True, but 'headers' was passed in kwargs. " - "The 'headers' parameter is injected by the worker and cannot be passed by the caller." - ) - task_func(*args, headers=headers, **kwargs) - else: - task_func(*args, **kwargs) - transaction.set_status(SPANSTATUS.OK) - except Exception: - transaction.set_status(SPANSTATUS.INTERNAL_ERROR) - raise + with contextlib.ExitStack() as stack: + with metrics.timer( + "taskworker.worker.context_rebuild.duration", + tags={ + "namespace": activation.namespace, + "taskname": activation.taskname, + }, + ): + for hook in context_hooks: + stack.enter_context(hook.on_execute(headers)) + if task_func.pass_headers: + if "headers" in kwargs: + raise TypeError( + f"Task '{task_func.name}' has pass_headers=True, but 'headers' was passed in kwargs. " + "The 'headers' parameter is injected by the worker and cannot be passed by the caller." + ) + task_func(*args, headers=headers, **kwargs) + else: + task_func(*args, **kwargs) def record_task_execution( activation: TaskActivation,