Fix asyncio event loop conflicts in CdpEvmWalletProvider#968
Fix asyncio event loop conflicts in CdpEvmWalletProvider#968darrylsj wants to merge 6 commits intocoinbase:mainfrom
Conversation
🟡 Heimdall Review Status
|
|
Great catch and thanks for the fix @darrylsj! Please fix the failing lint + unit tests |
|
We require commit signing, please rebase and verify your commits. |
|
Please also add a changelog entry https://github.com/coinbase/agentkit/blob/main/CONTRIBUTING-PYTHON.md#changelog |
|
CdpSvmWalletProvider and CdpSmartWalletProvider likely have the same issue, could you please do the equivalent changes there? |
- Replace asyncio.run() calls in __init__ with _run_async() helper - Improve _run_async() to detect existing event loops and handle them properly - Run coroutines in separate thread when event loop already exists - Prevents misleading ETIMEDOUT errors when real issue is asyncio conflict - Fixes compatibility with Jupyter notebooks, web frameworks, and agent systems Fixes coinbase#967
…anaWalletProvider; add changelog entry
0f17d85 to
2322f9e
Compare
|
Updated! Here's what's in this push:
CI runs are showing |
|
Please run the format and lint commands before committing @darrylsj |
|
Could you please fix the failing tests @darrylsj ? |
|
May take some time, but will get to them soon.
…On Mon, Mar 16, 2026 at 1:59 AM phdargen ***@***.***> wrote:
*phdargen* left a comment (coinbase/agentkit#968)
<#968 (comment)>
Could you please fix the failing tests @darrylsj
<https://github.com/darrylsj> ?
—
Reply to this email directly, view it on GitHub
<#968 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APNWUT7S5NND2HSOHTM6DLL4Q667PAVCNFSM6AAAAACV6X62GOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DANRWGEYDKMZWGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Darryl Sladden
|
- Sort __all__ lists in __init__.py files (RUF022) - Fix import block ordering in Solana test files (I001) - All ruff lint checks pass on changed files
|
Hey @phdargen — lint and test fixes are pushed! All 177 wallet provider tests pass, import sorting and |
Problem
Fixes #967
The
CdpEvmWalletProvider.__init__method was usingasyncio.run()which fails when an asyncio event loop is already running (common in Jupyter notebooks, web frameworks, and agent orchestration systems). This resulted in misleading "NetworkError(ETIMEDOUT, 'Request timed out')" errors when the real issue was asyncio event loop conflicts.Solution
asyncio.run()calls in__init__with the_run_async()helper method for consistency_run_async()method to properly detect and handle existing event loops:asyncio.get_running_loop()to detect if we're in an existing event loopChanges Made
coinbase_agentkit/wallet_providers/cdp_evm_wallet_provider.pyasyncio.run()with_run_async()_run_async()method with proper event loop handlingBenefits
Testing
The fix has been tested to ensure:
Note on Error Messages
This also addresses the misleading error message issue where asyncio conflicts were being reported as network timeouts. The new implementation allows the actual asyncio errors to propagate properly when they occur, making debugging much easier.
Dependencies
No new dependencies required - uses Python's built-in
concurrent.futuresandthreadingmodules.