|
12 | 12 | Infores, |
13 | 13 | KnowledgeGraphDict, |
14 | 14 | QueryGraphDict, |
15 | | - ResultDict, |
16 | 15 | ) |
17 | 16 | from retriever.utils.logs import TRAPILogger |
18 | 17 | from retriever.utils.trapi import ( |
@@ -43,21 +42,12 @@ async def execute(self) -> LookupArtifacts: |
43 | 42 | start_time = time.time() |
44 | 43 | self.job_log.info("Starting lookup against Tier 0...") |
45 | 44 |
|
46 | | - try: |
47 | | - timeout = None if self.ctx.timeout[0] < 0 else self.ctx.timeout[0] |
48 | | - self.job_log.debug( |
49 | | - f"Tier 0 timeout is {'disabled' if timeout is None else f'{timeout}s'}." |
50 | | - ) |
51 | | - async with asyncio.timeout(timeout): |
52 | | - backend_results = await self.get_results(self.qgraph) |
53 | | - |
54 | | - except TimeoutError: |
55 | | - self.job_log.error("Tier 0 operation timed out.") |
56 | | - backend_results = BackendResult( |
57 | | - results=list[ResultDict](), |
58 | | - knowledge_graph=KnowledgeGraphDict(nodes={}, edges={}), |
59 | | - auxiliary_graphs=dict[AuxGraphID, AuxiliaryGraphDict](), |
60 | | - ) |
| 45 | + timeout = None if self.ctx.timeout[0] < 0 else self.ctx.timeout[0] |
| 46 | + self.job_log.debug( |
| 47 | + f"Tier 0 timeout is {'disabled' if timeout is None else f'{timeout}s'}." |
| 48 | + ) |
| 49 | + async with asyncio.timeout(timeout): |
| 50 | + backend_results = await self.get_results(self.qgraph) |
61 | 51 |
|
62 | 52 | with tracer.start_as_current_span("update_kg"): |
63 | 53 | normalize_kgraph( |
@@ -90,10 +80,13 @@ async def execute(self) -> LookupArtifacts: |
90 | 80 | self.aux_graphs, |
91 | 81 | self.job_log.get_logs(), |
92 | 82 | ) |
93 | | - except Exception: |
94 | | - self.job_log.exception( |
95 | | - "Unhandled exception occurred while processing Tier 0. See logs for details." |
96 | | - ) |
| 83 | + except Exception as e: |
| 84 | + if isinstance(e, TimeoutError): |
| 85 | + self.job_log.error("Tier 0 operation timed out.") |
| 86 | + elif not isinstance(e, asyncio.exceptions.CancelledError): |
| 87 | + self.job_log.exception( |
| 88 | + "Unhandled exception occurred while processing Tier 0 query. See logs for details." |
| 89 | + ) |
97 | 90 | return LookupArtifacts( |
98 | 91 | [], self.kgraph, self.aux_graphs, self.job_log.get_logs(), error=True |
99 | 92 | ) |
|
0 commit comments