fix(weixin): remove _LIVE_ADAPTERS session reuse to avoid aiohttp timeout error - #22235
Closed
Scott1743 wants to merge 1 commit into
Closed
fix(weixin): remove _LIVE_ADAPTERS session reuse to avoid aiohttp timeout error#22235Scott1743 wants to merge 1 commit into
Scott1743 wants to merge 1 commit into
Conversation
Collaborator
…eout error aiohttp 3.13.5's asyncio.timeout() context guard fails when a session created with trust_env=True is reused from a ThreadPoolExecutor context via _run_async (loop.is_running()=True). The _LIVE_ADAPTERS optimization that reuses an existing adapter+session causes intermittent 'Timeout context manager should be used inside a task' errors. Fix: always create a fresh aiohttp.ClientSession per send_weixin_direct call instead of reusing _LIVE_ADAPTERS. This is slightly less efficient but eliminates the non-deterministic timeout failures.
Scott1743
force-pushed
the
pr/weixin-session-fix
branch
from
May 9, 2026 03:27
b75fdf7 to
2eb8624
Compare
Author
|
@alt-glitch Thanks for the context. Agreed on the root cause — this is the same pattern. If any of the prior PRs (#12810, #13361, #18890) is already merged or close to merge, happy to close this as duplicate and defer. If not, this PR stands. |
Contributor
|
Automated hermes-sweeper review: current main already fixes the Weixin direct-send aiohttp timeout failure this PR targets. Evidence:
The PR's broader approach of removing live-adapter reuse entirely is no longer needed for the reported cross-event-loop timeout failure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In aiohttp 3.13.5, context manager fails when a session created with is reused from a context via (where ).
The optimization that reuses an existing adapter+session across calls causes intermittent errors:
Fix
Always create a fresh per call instead of reusing . This is slightly less efficient but eliminates the non-deterministic timeout failures.
Changes