joblib loky backend leaks memory when stdout is piped through Claude Code; tqdm progress bar broken
Resolved 💬 3 comments Opened Mar 25, 2026 by Sr-11 Closed Mar 25, 2026
Disclaimer: This issue was generated by Claude Code. The problem is real and reproducible, but the root cause analysis below is Claude Code's best guess and may not be accurate.
Description
Two related issues when running Python scripts through Claude Code's Bash tool:
- joblib memory leak:
joblib.Parallelwith the defaultlokybackend leaks memory and eventually hangs or gets killed. - tqdm progress bar broken: tqdm progress bars render incorrectly — instead of updating in place, each update prints a new line, flooding the output.
Both work fine in a normal terminal.
Root cause (speculative)
Claude Code's Bash tool pipes stdout/stderr rather than allocating a PTY. This breaks:
lokyworker processes that inherit piped file descriptors- tqdm's
\rcarriage return for in-place updates (pipe doesn't support terminal control codes)
Reproduction
from joblib import Parallel, delayed
from tqdm import tqdm
import numpy as np
def work(i):
return np.random.randn(10000).mean()
# tqdm progress bar broken — prints new line per update instead of in-place
for _ in tqdm(range(100)):
pass
# joblib hangs/leaks in Claude Code, works in normal terminal
results = Parallel(n_jobs=8)(delayed(work)(i) for i in range(1000))
Environment
- macOS Darwin 25.3.0
- Python 3.12, joblib, tqdm, scikit-learn
- Claude Code (CLI)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗