sync update from LAN repo (source dhk-1 @ 3b1ec5b4)
This commit is contained in:
1 parent
da6521b6cb
commit
264e2200d6
995 files changed
+148105
-13399
No files matched your search
@@ -30,6 +30,8 @@ from app.gateway.roundtable_job_executor import (
|
||||
WORKER_ID,
|
||||
params_from_snapshot,
|
||||
)
|
||||
from deerflow.config.system_settings import get_roundtable_room_limit_settings
|
||||
from deerflow.persistence.roundtable_rooms.sql import NON_OCCUPYING_JOB_PHASES
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -125,6 +127,7 @@ class RoundtableJobDispatcher:
|
||||
async def dispatch_once(self) -> int:
|
||||
"""扫一轮可领取作业并逐个条件抢占。返回本轮成功启动的作业数。"""
|
||||
now = datetime.now(UTC)
|
||||
await self._expire_overdue_step2_rooms(now)
|
||||
await self._reap_cancel_requested(now)
|
||||
try:
|
||||
candidate_ids = await self._store.list_claimable(now=now, limit=_CLAIM_BATCH)
|
||||
@@ -172,6 +175,35 @@ class RoundtableJobDispatcher:
|
||||
)
|
||||
return started
|
||||
|
||||
async def _expire_overdue_step2_rooms(self, now: datetime) -> int:
|
||||
"""Persist hard-timeout cancellation even when no browser is connected."""
|
||||
max_minutes = getattr(
|
||||
get_roundtable_room_limit_settings(),
|
||||
"max_hold_minutes",
|
||||
30,
|
||||
)
|
||||
request_cancel_expired = getattr(
|
||||
self._store,
|
||||
"request_cancel_expired_step2",
|
||||
None,
|
||||
)
|
||||
if request_cancel_expired is None:
|
||||
return 0
|
||||
try:
|
||||
expired = await request_cancel_expired(
|
||||
created_before=now - timedelta(minutes=max_minutes),
|
||||
non_occupying_phases=tuple(NON_OCCUPYING_JOB_PHASES),
|
||||
)
|
||||
except Exception: # noqa: BLE001
|
||||
logger.warning("[roundtable-jobs] hard-timeout scan failed", exc_info=True)
|
||||
return 0
|
||||
if expired:
|
||||
logger.info(
|
||||
"[roundtable-jobs] requested cancellation for %d overdue Step-2 room(s)",
|
||||
expired,
|
||||
)
|
||||
return expired
|
||||
|
||||
async def _reap_cancel_requested(self, now: datetime) -> int:
|
||||
"""收口持租 worker 崩溃后遗留的 ``cancel_requested`` 作业。
|
||||
|
||||
|
||||
Reference in new issue
Block a user