From 1be060ab428879420b2a126a50c44a1c2d4a67b9 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sun, 1 Nov 2020 02:37:40 +0000 Subject: [PATCH] Fix Windows freeze support. BONKERS. --- launch_standalone.py | 16 ++++++++++------ player.py | 3 +-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/launch_standalone.py b/launch_standalone.py index f405f35..a37c247 100644 --- a/launch_standalone.py +++ b/launch_standalone.py @@ -5,24 +5,28 @@ import webbrowser from server import BAPSicleServer + def startServer(): - - # On Windows calling this function is necessary. - # Causes all kinds of loops if not present. - multiprocessing.freeze_support() - server = multiprocessing.Process(target=BAPSicleServer) server.start() while True: - time.sleep(2) + time.sleep(5) if server and server.is_alive(): pass else: print("Server dead. Exiting.") sys.exit(0) + if __name__ == '__main__': + # On Windows, calling this function is necessary. + # Causes all kinds of loops if not present. + # IT HAS TO BE RIGHT HERE, AT THE TOP OF __MAIN__ + # NOT INSIDE AN IF STATEMENT. RIGHT. HERE. + # If it's not here, multiprocessing just doesn't run in the package. + # Freeze support refers to being packaged with Pyinstaller. + multiprocessing.freeze_support() if len(sys.argv) > 1: # We got an argument! It's probably Platypus's UI. try: diff --git a/player.py b/player.py index 2c9343f..8129f35 100644 --- a/player.py +++ b/player.py @@ -18,7 +18,6 @@ from state_manager import StateManager from mutagen.mp3 import MP3 - class Player(): state = None running = False @@ -357,7 +356,7 @@ def showOutput(in_q, out_q): if __name__ == "__main__": - multiprocessing.set_start_method("spawn", True) + #multiprocessing.set_start_method("spawn", True) in_q = multiprocessing.Queue() out_q = multiprocessing.Queue()