Fix Windows freeze support. BONKERS.

This commit is contained in:
Matthew Stratford 2020-11-01 02:37:40 +00:00
parent d1b474962d
commit 1be060ab42
No known key found for this signature in database
GPG key ID: 5F50E4308A3416E8
2 changed files with 11 additions and 8 deletions

View file

@ -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:

View file

@ -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()