Skip to content

Commit fea727e

Browse files
committed
add configurable timeout
1 parent f70a993 commit fea727e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

backend/src/modules/llm_assistant/llm_job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
router=router,
1414
device="gpu",
1515
result_ttl=JobResultTTL.NINETY_DAYS,
16+
timeout=-1, # infinite/no timeout
1617
)
1718
def llm_assistant(
1819
payload: LLMJobInput,

backend/src/systems/job_system/job_register_decorator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def register_job(
2626
router: APIRouter | None = None,
2727
result_ttl: JobResultTTL = JobResultTTL.DEFAULT,
2828
retry: tuple[int, int] | None = None,
29+
timeout: int = 1800, # default timeout of 30 min (RQ default is 3 min [180])
2930
):
3031
def decorator(func: Callable[[InputT, Job], OutputT | None]):
3132
from systems.job_system.job_service import JobService
@@ -41,6 +42,7 @@ def decorator(func: Callable[[InputT, Job], OutputT | None]):
4142
router=router,
4243
result_ttl=result_ttl,
4344
retry=retry,
45+
timeout=timeout,
4446
)
4547
return func
4648

backend/src/systems/job_system/job_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class RegisteredJob(TypedDict):
4242
result_ttl: JobResultTTL # how long to keep successful jobs and their results (defaults to 500 seconds)
4343
# failure_ttl # how long to keep failed jobs (defaults to 1 year)
4444
# ttl # how long to keep jobs in queue before they are discarded (defaults to infinite)
45-
# timeout # specifies maximum runtime before the job is interrupted and marked as failed
4645
# see https://python-rq.org/docs/jobs/#job-creation
4746
retry: tuple[int, int] | None
47+
timeout: int # maximum runtime before the job is interrupted and marked as failed (in seconds)
4848

4949

5050
class JobService(metaclass=SingletonMeta):
@@ -103,6 +103,7 @@ def register_job(
103103
router: APIRouter | None,
104104
result_ttl: JobResultTTL,
105105
retry: tuple[int, int] | None,
106+
timeout: int,
106107
) -> None:
107108
# Enforce that the only parameter is named 'payload'
108109
sig = inspect.signature(handler_func)
@@ -130,6 +131,7 @@ def register_job(
130131
"router": router,
131132
"result_ttl": result_ttl,
132133
"retry": retry,
134+
"timeout": timeout,
133135
}
134136

135137
def start_job(

0 commit comments

Comments
 (0)