The compiled program using PyInstaller can't use the subprocess.Popen("python script.py") because the python interpreter isn't included. It can however use exec() but this leads to issues with how to save/terminate it, and subprocess doesn't seem to be usuable to call only functions like exec() (..?).
Tried switching from using subprocess to multiprocessing (branch: multiprocess):
Program can run the script, but there's no way to terminate it because the process variable (p) can't be referenced outside of runTraining() (p is not defined)
What should happen:
Pressing "Start training" starts a thread that runs the process of running trainGPT2.py through exec(). (Works)
Pressing "Save and end training" sends a SIGINT signal to the process, forcing it to save. (Doesn't work)
Because it's a threaded task (?) it will try saving, but immediately exit before it can fully save.
Sending the SIGINT (needed for it to save) only interrupts the process but does not stop it from running in the background, so the terminate is necessary.
Mainly because model deletion relies on booleans updated when pressing their respective "End" buttons, but in the case where the program exits by itself (steps reached, samples finished) the boolean is not updated.
Could use thread/genThread.wait(), but this would result in the program hanging until finished...
ifeventin (None, "Exit"):
iftrainingStarted:
sg.popup("Please save and end training before quitting the program.")
window.refresh()
else:
ifgenerationStarted:
q.terminate()
exit()
break
makes it so the popup shows once the app is closed, but the program still exits regardless.