mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-11 14:15:40 +08:00
fix: chat channel runtime (#16129)
### What problem does this PR solve? Fix chat channel message routing to use the connected `chat_id`, and make the Feishu websocket client bind to the thread-local event loop. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -8,6 +8,7 @@ from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
import lark_oapi as lark
|
||||
import lark_oapi.ws.client as lark_ws_client
|
||||
from lark_oapi.api.im.v1 import (
|
||||
CreateMessageRequest,
|
||||
CreateMessageRequestBody,
|
||||
@@ -73,6 +74,11 @@ class FeishuChannel(Channel):
|
||||
# context: already entered"). A dedicated isolated loop avoids that.
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
# lark_oapi.ws.client stores a module-level `loop` at import time and all
|
||||
# websocket task scheduling goes through that object. Rebind it here so
|
||||
# this Feishu channel uses the thread-local loop instead of the API
|
||||
# server's main loop.
|
||||
lark_ws_client.loop = loop
|
||||
try:
|
||||
handler = (
|
||||
lark.EventDispatcherHandler.builder("", "")
|
||||
|
||||
Reference in New Issue
Block a user