fix: bound task failures and release stalled workers
This commit is contained in:
1 parent
606ed94160
commit
1fdf7c0d1d
32 files changed
+1121
-93
No files matched your search
@@ -0,0 +1,30 @@
|
||||
"""Execution budgets shared by supervised web and MCP tasks."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
import time
|
||||
|
||||
from artemis.config.settings import settings
|
||||
|
||||
|
||||
def task_timeout(item: dict, job: dict | None = None, batch: dict | None = None) -> int:
|
||||
options = item.get("runtime_overrides") or (job or {}).get("case", {}).get("task_config") or {}
|
||||
return int(
|
||||
options.get("timeout_seconds")
|
||||
or (batch or {}).get("timeout_seconds")
|
||||
or settings.ARTEMIS_TASK_TIMEOUT_SECONDS
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ExecutionBudget:
|
||||
limit: float
|
||||
elapsed: float = 0
|
||||
_last: float = field(default_factory=time.monotonic)
|
||||
_excluded: bool = False
|
||||
|
||||
def update(self, *, excluded: bool = False) -> float:
|
||||
now = time.monotonic()
|
||||
if not self._excluded:
|
||||
self.elapsed += max(0, now - self._last)
|
||||
self._last, self._excluded = now, excluded
|
||||
return max(0, self.limit - self.elapsed)
|
||||
Reference in new issue
Block a user