Skip to content
Advertisement

input results in an EOFError only while in a different thread

The below code raises an EOF exception on the input statement.

JavaScript

output

JavaScript

although if mainloop is executed in the current thread, the error does not occur

JavaScript

output:

JavaScript

Advertisement

Answer

The problem cannot be solved. I have looked online and the only other thign that is related to this is this other stackoverflow question.https://stackoverflow.com/questions/42837544/python-3-multiprocessing-eoferror-eof-when-reading-a-line. Basically what is happening is the normal sys.stdin() that input uses is forbidden by multithreading, usually people can sidestep this by using the threading module. Sadly this is not possible because the two need to run together or they will both fail. If you execute this in the IDLE it will not show any text at all, I still have no idea why this happens. If you want this there is no current solution

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement