Files
tg_python/tg_bridge/winloop.py
2026-04-23 22:06:19 +08:00

16 lines
521 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Windows经 SOCKS 连接 Telegram 时Proactor 事件循环易触发 WinError 121信号灯超时
在启动任何 asyncio 代码之前调用 ``apply_windows_selector_policy()``。
参考asyncio 在 Windows 上默认 ProactorEventLoop 与部分 socket/代理场景不兼容。
"""
from __future__ import annotations
import asyncio
import sys
def apply_windows_selector_policy() -> None:
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())