feat: 采集和导出固定由排队进程执行

This commit is contained in:
2026-10-30 09:58:21 +08:00
parent 3fa4f83180
commit c232ccbec5
12 changed files with 36 additions and 59 deletions
+5 -9
View File
@@ -10,7 +10,7 @@ from sqlalchemy import select
from app.collect.io import parse_upload, write_table
from app.collect.remote import fetch_ftp, fetch_nqi
from app.config import inline_worker, postgres_conninfo, result_dir
from app.config import postgres_conninfo, result_dir
from app.db import session_scope
from app.models import CellData, CollectionSource, ExportTask, NqiAccount, utcnow
from app.nqi.client import NqiAuthError, NqiClient, NqiError
@@ -190,16 +190,12 @@ def enqueue_collection(source_id: int) -> None:
def _defer(name: str, **kwargs) -> bool:
if inline_worker() or not postgres_conninfo():
if not postgres_conninfo():
return False
try:
from app.tasks.queue import defer
from app.tasks.queue import defer
defer(name, **kwargs)
return True
except Exception as exc:
logger.info("排队未投递,改为本进程执行: %s", exc)
return False
defer(name, **kwargs)
return True
def scan_sources() -> None: