I am trying to get the input from one function while running another simultaneously that can then utilise that input. I would like the input to be a global variable so it can be utilised by several functions at the same time. I know this works in multithreading but I CAN NOT use multithreading for other reasons. I tried the code below but I get the following error...
import time
user = ""
def printy(choice):
while True:
print(choice)
time.sleep(1)
def inputy():
global user
while True:
user = input("input: ")
if __name__ == '__main__':
p1 = m.Process(target=printy, args=[user, ])
p2 = m.Process(target=inputy)
p1.start()
p2.start()
ERROR I GET:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/Users/julian/PycharmProjects/game/new/mpmp.py", line 15, in inputy
user = input("input: ")
EOFError: EOF when reading a line```