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