feat: 采集和导出固定由排队进程执行
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""PostgreSQL 上的 Procrastinate 队列。SQLite 或本进程模式不走这里。"""
|
||||
"""PostgreSQL 上的 Procrastinate 队列。采集和导出都由排队进程执行。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user