Skip to content

Commit 8aab2b7

Browse files
committed
float timeout for sub-second jobs
1 parent 543716e commit 8aab2b7

6 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/retriever/data_tiers/tier_0/base_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def execute(self) -> LookupArtifacts:
4545
self.job_log.info("Starting lookup against Tier 0...")
4646

4747
try:
48-
timeout = None if self.ctx.timeout < 0 else self.ctx.timeout - 0.5
48+
timeout = None if self.ctx.timeout < 0 else self.ctx.timeout
4949
async with asyncio.timeout(timeout):
5050
backend_results = await self.get_results(
5151
QueryGraphDict(**self.qgraph.model_dump())

src/retriever/lookup/qgx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ async def execute_branch(
235235
while parallel_tasks:
236236
timeout = (
237237
max(
238-
self.ctx.timeout - (time.time() - self.start_time) - 0.5,
238+
self.ctx.timeout - (time.time() - self.start_time),
239239
0,
240240
)
241241
if self.ctx.timeout >= 0
@@ -561,7 +561,7 @@ async def timeout(self) -> None:
561561
try:
562562
if self.ctx.timeout < 0:
563563
return
564-
await asyncio.sleep(max(self.ctx.timeout - 0.5, 0))
564+
await asyncio.sleep(self.ctx.timeout)
565565
self.job_log.error("QGX hit timeout, attempting wrapup...")
566566
self.terminate = True
567567
except asyncio.CancelledError:

src/retriever/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def make_query(
6060
Unhandled errors are handled by middleware.
6161
"""
6262
job_id = uuid.uuid4().hex
63-
timeout: int = {
63+
timeout: float = {
6464
"lookup": CONFIG.job.lookup.timeout,
6565
"metakg": CONFIG.job.metakg.timeout,
6666
}[func]

src/retriever/types/general.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class QueryInfo(NamedTuple):
5454
body: Query | AsyncQuery | None
5555
job_id: str
5656
tiers: set[TierNumber]
57-
timeout: int
57+
timeout: float
5858

5959

6060
class BackendResults(TypedDict):

src/retriever/types/trapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ParametersDict(TypedDict):
2525
"""Query Parameters."""
2626

2727
tiers: list[int]
28-
timeout: int
28+
timeout: float
2929

3030

3131
class QueryDict(TypedDict):

src/retriever/types/trapi_pydantic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Parameters(BaseModel):
1515
"""Parameters that govern some elements of query execution behavior."""
1616

1717
timeout: Annotated[
18-
int | None,
18+
float | None,
1919
Field(
2020
description="Custom query timeout in seconds. Defaults to server default if not set. Set to -1 to disable timeout entirely."
2121
),

0 commit comments

Comments
 (0)