mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix(weixin): send_weixin_direct cross-loop session check
When send_message tool is called from inside a running gateway, the _run_async bridge spawns a worker thread with a separate event loop. send_weixin_direct then reuses the live adapter's aiohttp session which was created on the gateway's main loop. aiohttp's TimerContext checks asyncio.current_task(loop=session._loop) and sees None because we're executing on the worker thread's loop → raises 'Timeout context manager should be used inside a task'. Fix: skip the live-adapter shortcut when the session belongs to a different event loop, falling through to the fresh-session path.
This commit is contained in:
parent
9987f3d824
commit
a22465e07a
1 changed files with 3 additions and 1 deletions
|
|
@ -2030,7 +2030,9 @@ async def send_weixin_direct(
|
||||||
|
|
||||||
live_adapter = _LIVE_ADAPTERS.get(resolved_token)
|
live_adapter = _LIVE_ADAPTERS.get(resolved_token)
|
||||||
send_session = getattr(live_adapter, '_send_session', None)
|
send_session = getattr(live_adapter, '_send_session', None)
|
||||||
if live_adapter is not None and send_session is not None and not send_session.closed:
|
if (live_adapter is not None and send_session is not None
|
||||||
|
and not send_session.closed
|
||||||
|
and send_session._loop is asyncio.get_running_loop()):
|
||||||
last_result: Optional[SendResult] = None
|
last_result: Optional[SendResult] = None
|
||||||
cleaned = live_adapter.format_message(message)
|
cleaned = live_adapter.format_message(message)
|
||||||
if cleaned:
|
if cleaned:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue