I need an input() in a process for my application. I wrote a small test because I have experienced some problems with it.
from multiprocessing import Process, Queue
class InputCatcher(Process):
def __init__(self, input_queue):
Process.__init__(self)
self.input_queue = input_queue
def run(self):
while True:
self.input_queue.put(input())
input_queue = Queue()
ic = InputCatcher(input_queue)
ic.daemon = True
ic.start()
while True:
if not input_queue.empty():
print(input_queue.get())
Unfortunately I get this error:
Process InputCatcher-1:
Traceback (most recent call last):
File "/usr/lib/python3.3/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/****/PycharmProjects/****/test/inputtestproces.py", line 13, in run
self.input_queue.put(input())
EOFError: EOF when reading a line
Is there a way to get this to work?