初始化
This commit is contained in:
15
tg_bridge/winloop.py
Normal file
15
tg_bridge/winloop.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""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())
|
||||
Reference in New Issue
Block a user