mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-19 12:24:46 +08:00
fix: configure Windows event loop policy for PostgreSQL async compatibility (#618)
- Set asyncio.WindowsSelectorEventLoopPolicy() on Windows at app module level - Ensures psycopg can run in async mode on Windows regardless of entry point - Fixes 'ProactorEventLoop' error when using PostgreSQL checkpointer - Works with all entry points: server.py, uvicorn, langgraph dev, etc.
This commit is contained in:
committed by
Willem Jiang
parent
9b127c55f2
commit
120fcfb316
@@ -1,9 +1,11 @@
|
|||||||
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from typing import Annotated, Any, List, cast
|
from typing import Annotated, Any, List, cast
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
@@ -52,6 +54,11 @@ from src.utils.json_utils import sanitize_args
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Configure Windows event loop policy for PostgreSQL compatibility
|
||||||
|
# On Windows, psycopg requires a selector-based event loop, not the default ProactorEventLoop
|
||||||
|
if os.name == "nt":
|
||||||
|
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||||
|
|
||||||
INTERNAL_SERVER_ERROR_DETAIL = "Internal Server Error"
|
INTERNAL_SERVER_ERROR_DETAIL = "Internal Server Error"
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
|
|||||||
Reference in New Issue
Block a user