Skip to content

fix(python): remove nest-asyncio dependency for Python 3.12+ compatibility#651

Open
Kubudak90 wants to merge 1 commit into
coinbase:mainfrom
Kubudak90:fix/remove-nest-asyncio-py312
Open

fix(python): remove nest-asyncio dependency for Python 3.12+ compatibility#651
Kubudak90 wants to merge 1 commit into
coinbase:mainfrom
Kubudak90:fix/remove-nest-asyncio-py312

Conversation

@Kubudak90

Copy link
Copy Markdown

Summary

Closes #591.

Removes the "nest-asyncio" dependency and replaces it with a thread-safe fallback in .

Problem

is incompatible with Python 3.12+ in environments using or other modern async loops, causing runtime errors when synchronous methods on are called from an already-running event loop.

Solution

If no event loop is running, uses directly.
If an event loop is already running, the coroutine is executed in a background thread, where can safely create a new loop.

This approach is standard, does not require patching the event loop, and works correctly across all supported Python versions.

Changes

  • Removed and from
  • Rewrote to use as a fallback
  • Removed from dependencies
  • Updated accordingly

Testing

  • All 11 tests in pass
  • Manually verified behavior in three scenarios:
    1. No running event loop
    2. Inside a running event loop
    3. Nested running event loops

…ility

Replace nest_asyncio with a thread-safe _run_async fallback that
uses ThreadPoolExecutor when called from an already-running event
loop. This restores compatibility with Python 3.12+ and uvicorn.

Fixes coinbase#591
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant