1

I have some code that goes like this:

from multiprocessing import Process

def foo():
    while True:
        f=input('Input: ')
        print('Why doesn't this print?')

if __name__=='__main__':    
    p1 = Process(target=bruh)
    print('this prints')
    p1.start()
    print('and so does this')

But when ran, I recieve this error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python38-32\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()

  File "C:\Program Files (x86)\Python38-32\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)

  File "C:\Users\(myUsername)\Desktop\program.py", line 739, in foo
    f=input('still running')

EOFError: EOF when reading a line

I belive this is because the process ended when it reached the input function, causing it to give an end of field error, but I don't know. Please Help!

(using python 3.8.3)

maha
  • 643
  • 5
  • 20
Amber Cahill
  • 106
  • 8

2 Answers2

0

EOF errors usually are caused by mistakes at the end of the line, like a missing parenthesis or something similar. Try indenting the if into the loop inside the function.

If that doesn't work, maybe you wrote print('Why doesn't this print?') instead of print("Why doesn't this print?")

Gryu
  • 2,102
  • 2
  • 16
  • 29
Rexus_9
  • 16
  • 3
0

You have a single quote ' here: doesn't

print('Why doesn't this print?')

Try to escape it by \', or try without it first:

print('Why does this not print?')

Double quotes also could be a solution in this case.

In my case PyCharm interprets this error as SyntaxError: invalid syntax and highlights a t in doesn't as an Unresolved reference expecting , or ).

So maybe the issue is not in the provided piece of code, but somewhere else. Look at lines displayed in errors. Maybe you've forget to close some single quote ' somewhere else

Gryu
  • 2,102
  • 2
  • 16
  • 29
  • While the question makes this mistake, the error shown indicates that is not the problem in the actual code. Incorrect literals produce ``SyntaxError: EOL while scanning string literal``, not an ``EOFError``. – MisterMiyagi Aug 06 '20 at 08:05