Skip to content

fix(python): reuse tokio runtime instead of creating per call#451

Merged
chaliy merged 1 commit intomainfrom
claude/fix-414-Y2nIj
Mar 1, 2026
Merged

fix(python): reuse tokio runtime instead of creating per call#451
chaliy merged 1 commit intomainfrom
claude/fix-414-Y2nIj

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 1, 2026

Summary

  • Store shared tokio::runtime::Runtime in PyBash, BashTool, and ScriptedTool structs
  • Use Builder::new_current_thread() for lighter weight since multi-threaded isn't needed
  • Eliminates OS thread/fd exhaustion under rapid-fire calls

Closes #414

Test plan

  • Tests call execute_sync/reset 200 times each on all tool types
  • cargo clippy and cargo fmt pass
  • cargo test passes

Store a shared `tokio::runtime::Runtime` (current-thread) in PyBash,
BashTool, and ScriptedTool structs. Previously each `execute_sync()`
and `reset()` call created a new runtime, spawning OS threads that
could exhaust thread/fd limits under rapid-fire usage.

Fixes #414

https://claude.ai/code/session_01WZjYqxm5xMPAEe7FSHJkDy
@chaliy chaliy force-pushed the claude/fix-414-Y2nIj branch from c3c0466 to 3ff63a1 Compare March 1, 2026 09:03
@chaliy chaliy merged commit 1177d91 into main Mar 1, 2026
17 checks passed
@chaliy chaliy deleted the claude/fix-414-Y2nIj branch March 12, 2026 03:41
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.

[H-8] Tokio runtime created per sync call (resource exhaustion)

2 participants