fix: setup WindowsSelectorEventLoopPolicy in the first place #741 (#742)

* fix: setup WindowsSelectorEventLoopPolicy in the first place #741

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
This commit is contained in:
Willem Jiang
2025-12-06 22:10:13 +08:00
committed by GitHub
parent 3191e81939
commit 3bf4e1defb

View File

@@ -1,2 +1,11 @@
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
# SPDX-License-Identifier: MIT
import asyncio
import os
# Configure Windows event loop policy for PostgreSQL compatibility
# On Windows, psycopg requires a selector-based event loop, not the default ProactorEventLoop
# This must be set at the earliest possible point before any event loop is created
if os.name == "nt":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())