diff --git a/app/api/qgis_map_export.py b/app/api/qgis_map_export.py index 62ab76b..747e26c 100644 --- a/app/api/qgis_map_export.py +++ b/app/api/qgis_map_export.py @@ -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 线程池已关闭") \ No newline at end of file diff --git a/app/core/server.py b/app/core/server.py index 46711dd..4b05f71 100644 --- a/app/core/server.py +++ b/app/core/server.py @@ -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: diff --git a/app/script/export_static_layers.py b/app/script/export_static_layers.py index 6df97cd..602dd96 100644 --- a/app/script/export_static_layers.py +++ b/app/script/export_static_layers.py @@ -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"), diff --git a/settings.toml b/settings.toml index 3329b82..a12b83f 100644 --- a/settings.toml +++ b/settings.toml @@ -19,8 +19,6 @@ QGIS_DEFAULTS_ZOOM_VALUE = "50" QGIS_DEFAULTS_MAP_UNIT = "制图单位:西安市应急管理局" # 专题图DPI QGIS_EXPORT_DPI = 300 -# 批量产图线程池 -QGIS_WORKER_THREADS = 4 # 并行子进程数(每进程独立 QGIS 实例) QGIS_PARALLEL_WORKERS = 4