feat: 优化WebSocket连接和心跳机制
- 在main.py和standalone.py中添加ws_ping_interval和ws_ping_timeout配置 - 调整ws.py中的心跳发送逻辑,先发送ping再等待 - 在host_client中优化消息处理,使用任务队列处理转发请求 - 更新WebTool以适配新的API格式并增加搜索结果限制 - 在agent.py中添加日期显示和web调用次数限制 - 修复bot/handler.py中的事件循环问题
This commit is contained in:
@@ -184,6 +184,14 @@ def start_websocket_client(loop: asyncio.AbstractEventLoop) -> None:
|
||||
backoff = 1.0
|
||||
max_backoff = 60.0
|
||||
|
||||
# lark_oapi.ws.client captures the event loop at module import time.
|
||||
# In standalone mode uvicorn already owns the main loop, so we create
|
||||
# a fresh loop for this thread and redirect the lark module to use it.
|
||||
thread_loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(thread_loop)
|
||||
import lark_oapi.ws.client as _lark_ws_client
|
||||
_lark_ws_client.loop = thread_loop
|
||||
|
||||
while True:
|
||||
try:
|
||||
_ws_connected = False
|
||||
|
||||
Reference in New Issue
Block a user