Fix infinite spawn loop on Windows PyInstaller builds
CRITICAL FIX: Added multiprocessing.freeze_support() to prevent the frozen executable from spawning infinite copies of itself on Windows. The issue: When PyInstaller bundles Python apps that use multiprocessing (which PyTorch, faster-whisper, and RealtimeSTT all use), Windows treats each spawn as a new process that re-executes the script. Without freeze_support(), this creates an infinite loop of processes spawning until the system crashes. The fix: - Added multiprocessing.freeze_support() at the very top of main.py - Called before any imports that might use multiprocessing - Windows-only (wrapped in sys.platform check) - Must be before QApplication or any Qt imports This is a standard requirement for all PyInstaller apps that use multiprocessing on Windows. Resolves: App spawns infinite copies when running from PyInstaller build 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
6
main.py
6
main.py
@@ -8,8 +8,14 @@ optional multi-user server synchronization.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import multiprocessing
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
# CRITICAL: Must be called before anything else on Windows with PyInstaller
|
||||||
|
# This prevents the infinite spawning loop when the frozen executable runs
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
multiprocessing.freeze_support()
|
||||||
|
|
||||||
# Add project root to Python path
|
# Add project root to Python path
|
||||||
project_root = Path(__file__).parent
|
project_root = Path(__file__).parent
|
||||||
sys.path.insert(0, str(project_root))
|
sys.path.insert(0, str(project_root))
|
||||||
|
|||||||
Reference in New Issue
Block a user