|
1 | 1 | import logging |
2 | 2 | from typing import Any |
3 | 3 |
|
4 | | -from common_library.error_codes import create_error_code |
5 | 4 | from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient |
6 | 5 |
|
7 | | -from ..logging_errors import create_troubleshootting_log_kwargs |
8 | 6 | from ._rabbit import lrt_client, lrt_server |
9 | 7 | from ._rabbit.namespace import get_namespace |
10 | 8 | from .base_long_running_manager import BaseLongRunningManager |
11 | | -from .errors import TaskNotCompletedError, TaskNotFoundError |
12 | 9 | from .models import TaskBase, TaskContext, TaskId, TaskStatus |
13 | 10 | from .task import RegisteredTaskName |
14 | 11 |
|
@@ -97,41 +94,12 @@ async def get_task_result( |
97 | 94 | task_context: TaskContext, |
98 | 95 | task_id: TaskId, |
99 | 96 | ) -> Any: |
100 | | - try: |
101 | | - task_result = await lrt_client.get_task_result( |
102 | | - rabbitmq_rpc_client, |
103 | | - long_running_manager.rabbit_namespace, |
104 | | - task_context=task_context, |
105 | | - task_id=task_id, |
106 | | - ) |
107 | | - await lrt_client.remove_task( |
108 | | - rabbitmq_rpc_client, |
109 | | - long_running_manager.rabbit_namespace, |
110 | | - task_id=task_id, |
111 | | - task_context=task_context, |
112 | | - reraise_errors=False, |
113 | | - ) |
114 | | - return task_result |
115 | | - except (TaskNotFoundError, TaskNotCompletedError): |
116 | | - raise |
117 | | - except Exception as exc: |
118 | | - _logger.exception( |
119 | | - **create_troubleshootting_log_kwargs( |
120 | | - user_error_msg=f"{task_id=} raised an exception while getting its result", |
121 | | - error=exc, |
122 | | - error_code=create_error_code(exc), |
123 | | - error_context={"task_context": task_context, "task_id": task_id}, |
124 | | - ), |
125 | | - ) |
126 | | - # the task shall be removed in this case |
127 | | - await lrt_client.remove_task( |
128 | | - rabbitmq_rpc_client, |
129 | | - long_running_manager.rabbit_namespace, |
130 | | - task_id=task_id, |
131 | | - task_context=task_context, |
132 | | - reraise_errors=False, |
133 | | - ) |
134 | | - raise |
| 97 | + return await lrt_client.get_task_result( |
| 98 | + rabbitmq_rpc_client, |
| 99 | + long_running_manager.rabbit_namespace, |
| 100 | + task_context=task_context, |
| 101 | + task_id=task_id, |
| 102 | + ) |
135 | 103 |
|
136 | 104 |
|
137 | 105 | async def remove_task( |
|
0 commit comments