Initial public release
GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from app.db.session import SessionLocal
|
||||
from app.models import AoiOperation
|
||||
from app.services.aoi_operation_executor import AoiOperationExecutor
|
||||
|
||||
|
||||
logger = logging.getLogger("geointel.aoi_worker")
|
||||
|
||||
|
||||
class AoiOperationWorker:
|
||||
@staticmethod
|
||||
def run_once() -> int:
|
||||
db = SessionLocal()
|
||||
try:
|
||||
rows = db.query(AoiOperation).filter(AoiOperation.status.in_(("queued", "running"))).order_by(AoiOperation.created_at).limit(10).all()
|
||||
for operation in rows:
|
||||
try:
|
||||
AoiOperationExecutor.execute_next(db, operation.project_id, operation.id)
|
||||
except Exception:
|
||||
db.rollback()
|
||||
logger.exception("AOI partition execution failed operation_id=%s", operation.id)
|
||||
return len(rows)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
@staticmethod
|
||||
async def run(stop_event: asyncio.Event, poll_seconds: float) -> None:
|
||||
while not stop_event.is_set():
|
||||
processed = await asyncio.to_thread(AoiOperationWorker.run_once)
|
||||
if processed == 0:
|
||||
try:
|
||||
await asyncio.wait_for(stop_event.wait(), timeout=poll_seconds)
|
||||
except TimeoutError:
|
||||
pass
|
||||
Reference in New Issue
Block a user