fix: remove nest_asyncio dependency for Python 3.12+ compatibility#637
Open
Kubudak90 wants to merge 2 commits intocoinbase:mainfrom
Open
fix: remove nest_asyncio dependency for Python 3.12+ compatibility#637Kubudak90 wants to merge 2 commits intocoinbase:mainfrom
Kubudak90 wants to merge 2 commits intocoinbase:mainfrom
Conversation
🟡 Heimdall Review Status
|
added 2 commits
April 6, 2026 08:10
Updates web3 dependency from <=7.10.0 to <8.0.0 to allow the security fix for GHSA-5hr4-253g-cpx2 (SSRF via CCIP Read) which shipped in web3.py v7.15.0. Fixes coinbase#636
…ility Replace nest_asyncio with a thread-based approach for running async code from synchronous contexts. This fixes compatibility issues with Python 3.12+ and modern uvicorn which use loop_factory parameter that nest_asyncio doesn't support. Changes: - Remove nest_asyncio dependency from pyproject.toml - Update _run_async() to use ThreadPoolExecutor when inside a running event loop - This avoids global asyncio monkey-patching while maintaining Jupyter notebook support Fixes coinbase#591
b0c8771 to
f9b6ad7
Compare
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.
Summary
Fixes #591 - Removes the unmaintained
nest_asynciolibrary which is incompatible with Python 3.12+ and modern uvicorn.Problem
nest_asynciomonkey-patchesasyncio.run()with a signature that doesn't support theloop_factoryparameter introduced in Python 3.12. This causes failures when using modern uvicorn or other async frameworks:Additionally,
nest_asynciois no longer maintained.Solution
Replaced
nest_asynciowith a modern, non-monkey-patching approach:_is_event_loop_running()- Detects if we're already in an event loop_run_async()- Handles both sync and async contexts:asyncio.run_coroutine_threadsafe()for safe executionasyncio.run()nest-asynciofrom dependencies inpyproject.tomlChanges
python/cdp/evm_local_account.py: Removed nest_asyncio, updated async handlingpython/pyproject.toml: Removed nest-asyncio dependencyTesting
The new implementation maintains backward compatibility while fixing Python 3.12+ issues. The
_run_asyncfunction is used internally byEvmLocalAccountfor signing operations.Checklist