Skip to content

Commit

Permalink
♻️ anyio support
Browse files Browse the repository at this point in the history
  • Loading branch information
StarHeartHunt committed Oct 31, 2024
1 parent 8c8902a commit 2461537
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nonebot/adapters/feishu/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, driver: Driver, **kwargs: Any):
"""飞书适配器配置"""
self.feishu_config: Config = get_plugin_config(Config)
self.bot_apps: dict[str, BotConfig] = {}
self.tasks: set["asyncio.Task"] = set()
self.setup()

@classmethod
Expand Down Expand Up @@ -271,7 +272,10 @@ async def _handle_http(self, request: Request) -> Response:
raise RuntimeError("Corresponding Bot instance not found")

if event := self.json_to_event(data):
asyncio.create_task(cast(Bot, bot).handle_event(event))
bot = cast(Bot, bot)
task = asyncio.create_task(bot.handle_event(event))
task.add_done_callback(self.tasks.discard)
self.tasks.add(task)

return Response(200)

Expand Down

0 comments on commit 2461537

Please sign in to comment.