18 lines
589 B
Python
18 lines
589 B
Python
"""Uvicorn 在 Windows 上默认选用 ``ProactorEventLoop``(见 ``uvicorn/loops/asyncio.py``),
|
||
与 Telethon 经 SOCKS 连接 Telegram DC 时常触发 ``WinError 121``;login_cli 使用 Selector 故正常。
|
||
|
||
本模块提供给 Uvicorn 的 ``loop_factory``,强制使用 ``SelectorEventLoop``。
|
||
|
||
命令行示例::
|
||
|
||
uvicorn tg_bridge.app:app --host 0.0.0.0 --port 18080 --loop tg_bridge.uvicorn_loop:selector_loop_factory
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import asyncio
|
||
|
||
|
||
def selector_loop_factory() -> asyncio.AbstractEventLoop:
|
||
return asyncio.SelectorEventLoop()
|