From 52aa73bfaae257397bfea4920992414594c44962 Mon Sep 17 00:00:00 2001 From: jknapp Date: Sun, 28 Dec 2025 20:17:23 -0800 Subject: [PATCH] Fix infinite spawn loop on all platforms with PyInstaller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extended the freeze_support fix to work on Linux and macOS, not just Windows. The spawn loop can occur on any platform when PyInstaller bundles apps that use multiprocessing. Changes: - Removed Windows-only condition for freeze_support() - Added multiprocessing.set_start_method('spawn', force=True) - Set spawn method for consistency across all platforms - Prevents fork-related issues on Linux with PyInstaller Why this is needed: - PyTorch, faster-whisper, and RealtimeSTT all use multiprocessing - PyInstaller frozen executables need explicit spawn method configuration - Linux defaults to 'fork' which can cause issues with frozen executables - 'spawn' method is more reliable with PyInstaller on all platforms This ensures the app launches only once on Windows, Linux, and macOS. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 4b87309..ffedd40 100644 --- a/main.py +++ b/main.py @@ -11,10 +11,18 @@ import sys import multiprocessing from pathlib import Path -# CRITICAL: Must be called before anything else on Windows with PyInstaller +# CRITICAL: Must be called before anything else with PyInstaller # This prevents the infinite spawning loop when the frozen executable runs -if sys.platform == 'win32': - multiprocessing.freeze_support() +# Required on all platforms (Windows, Linux, macOS) when using multiprocessing +multiprocessing.freeze_support() + +# Set multiprocessing start method to 'spawn' for consistency across platforms +# This prevents issues with PyInstaller frozen executables +if __name__ == "__main__": + try: + multiprocessing.set_start_method('spawn', force=True) + except RuntimeError: + pass # Already set, ignore # Add project root to Python path project_root = Path(__file__).parent