Skip to content

Your lightweight open-source personal agent.

Fix deadlock: get_group_member_info blocks receive loop

LZDQ0c3063b78ccf
diff --git a/nanobot/channels/napcat.py b/nanobot/channels/napcat.py
index 0caf4063c..64c0ac8dd 100644
--- a/nanobot/channels/napcat.py
+++ b/nanobot/channels/napcat.py
@@ -198,9 +198,9 @@ class NapcatChannel(BaseChannel):
post_type = payload.get("post_type")
if post_type == "message":
- await self._on_message(payload)
+ asyncio.create_task(self._on_message(payload))
elif post_type == "notice":
- await self._on_notice(payload)
+ asyncio.create_task(self._on_notice(payload)) # avoid deadlock
# ------------------------------------------------------------------
# Inbound: messages
@@ -390,6 +390,7 @@ class NapcatChannel(BaseChannel):
{"group_id": group_id, "user_id": user_id, "no_cache": True},
)
data = resp.get("data", {})
+ # logger.debug("get_group_member_info: {}", resp)
return data.get("card") or data.get("nickname") or str(user_id)
except Exception as e:
logger.warning("napcat: get_group_member_info failed: {}", e)