Skip to content

Conversation

@torykit
Copy link

@torykit torykit commented Nov 13, 2025

Description

Fixes: #324

Fixes issue where shutil.which("claude") in SubprocessCLITransport.__init__() blocks the event loop, causing blockbuster.BlockingError in async environments like LangGraph.

Changes

  • Move CLI path lookup from __init__() to connect() method
  • Use asyncio.to_thread() to run blocking operation in background thread
  • No breaking changes to public API

Files Modified

  • src/claude_agent_sdk/_internal/transport/subprocess_cli.py

Testing

  • ✅ Fixes blockbuster.BlockingError in async environments
  • ✅ Maintains all existing functionality
  • ✅ No breaking changes

- Move shutil.which() call from __init__ to connect() method
- Use asyncio.to_thread() to run _find_cli() in background thread
- Prevents blockbuster library from detecting os.access as blocking call
- Maintains backward compatibility and minimal code changes

Resolves issue where SDK would fail in async environments with
blocking call detection libraries like blockbuster.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

@SamueleTorregrossa SamueleTorregrossa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shutil.which() blocking call causes BlockingError in async environments

2 participants