- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 223
 
Open
Description
Environment
- mlx-audio: v0.2.5
 - Model: 
mlx-community/Kokoro-82M-bf16 - Python: 3.13.7
 - Machine: MacBook Pro M3 Pro (18GB RAM)
 - OS: macOS 26.0.1
 
Issue
Getting persistent semaphore leak warnings from Python's resource_tracker when using mlx-audio for real-time TTS:
INFO:whisperlivekit.audio_processor:internal_buffer=0.00s | lag=0.29s |
/Users/mohammedyasinmulla/.local/share/uv/python/cpython-3.13.7-macos-aarch64-none/lib/python3.13/multiprocessing/resource_tracker.py:324: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown: {'/loky-12097-8myixz42'}
When it occurs:
- At first audio generation (client connection)
 
Attempted Fixes
- ✅ Set 
LOKY_MAX_CPU_COUNT=1→ Reduced warnings but still appear occasionally - ✅ Explicit loky cleanup:
from joblib.externals.loky import get_reusable_executor executor = get_reusable_executor(max_workers=None, timeout=1) executor.shutdown(wait=True, kill_workers=True)
 - ✅ Aggressive GC → Minimal impact
 - ✅ Force CPU mode (disabled MPS) → Improved stability, warnings persist
 
Questions
- Does mlx-audio use 
joblibinternally? (I see it's in dependencies) - Is there a recommended async pattern for long-running services?
 - Are there known Python 3.13.7 compatibility issues?
 - Does 
model.generate()spawn background processes? - Proper cleanup procedure for MLX models in async context?
 
Related:
- Also using 
mlx-whisper(via WhisperLiveKit) in same process - Both may involve joblib/loky → cumulative effect?
 
Metadata
Metadata
Assignees
Labels
No labels