删除多线程产图

This commit is contained in:
wzy-warehouse
2026-06-21 15:29:39 +08:00
parent 95a74d00f3
commit 7e59d1b3f5
4 changed files with 0 additions and 28 deletions
-17
View File
@@ -28,14 +28,6 @@ logger = get_logger("api.qgis")
router = APIRouter(prefix="/qgis", tags=["专题图导出"])
# 线程池(按配置初始化 worker 数量)
_worker_threads = getattr(settings, "QGIS_WORKER_THREADS", 4)
_thread_pool = concurrent.futures.ThreadPoolExecutor(
max_workers=_worker_threads,
thread_name_prefix="qgis-worker",
)
logger.info(f"QGIS 线程池初始化: {_worker_threads} workers")
# 去重锁
_in_progress_locks: dict[str, asyncio.Lock] = {}
_locks_lock = asyncio.Lock()
@@ -478,12 +470,3 @@ def _generate_maps_subprocess(chunk_models: list, config: dict, chunk_idx: int)
logger.warning(f"[子进程{chunk_idx}] 无输出")
return []
# ============================================================
# 清理函数
# ============================================================
def shutdown_thread_pool() -> None:
"""关闭线程池(在 server.py lifespan 关闭阶段调用)"""
_thread_pool.shutdown(wait=False)
logger.info("QGIS 线程池已关闭")
-7
View File
@@ -36,13 +36,6 @@ async def lifespan(app: FastAPI):
yield
# 清理资源
try:
from app.api.qgis_map_export import shutdown_thread_pool
shutdown_thread_pool()
except Exception:
pass
logger.info("应用关闭")
def create_app() -> FastAPI:
-2
View File
@@ -27,7 +27,6 @@ GPKG_DIR = os.path.join(project_root, "app", "data", "gpkg")
# 静态图层定义: {显示名: (schema.table, gpkg文件名)}
STATIC_LAYERS = [
# ── 基础底图(已导出)──
("水库", "qgis.rivers", "rivers.gpkg"),
("市州驻地", "qgis.sx_capital", "sx_capital.gpkg"),
("河流", "qgis.river", "river.gpkg"),
@@ -44,7 +43,6 @@ STATIC_LAYERS = [
("traffic_railway", "qgis.traffic_railway", "traffic_railway.gpkg"),
("traffic_township", "qgis.traffic_township", "traffic_township.gpkg"),
("traffic_trunk_line", "qgis.traffic_trunk_line", "traffic_trunk_line.gpkg"),
# ── 新增静态表(消除数据库连接)──
("积水点", "qgis.hazard_hydrops", "hazard_hydrops.gpkg"),
("排水口", "qgis.lifeline_outfall", "lifeline_outfall.gpkg"),
("供水管网", "qgis.lifeline_pipe", "lifeline_pipe.gpkg"),