I am trying to communicate with a pygame inside a single .py file. The pygame uses a subprocess Popen to send output and receive input from my file, and my file uses sys.stdout to send stuff back. My file currently looks like the following:
if __name__ == "__main__":
while True:
if sys.stdin.isatty():
sys.stdin.close()
sys.stdout.close()
else:
print('a')
However, it gets about 5 seconds into the pygame (during which time communication appears to work), then the pygame freezes and the error thrown is a broken pipe error:
Traceback (most recent call last):
File "myfile.py", line 27, in <module>
print('a')
BrokenPipeError: [Errno 32] Broken pipe
I can't change the pygame, so any tips and help to accomodate for the subprocess potentially closing inside the pygame would be greatly appreciated!