3

Suppose I have two functions

def ticker():
    while True:
        print("Hello")
        time.sleep(60)

def main():
    while True:
        message = input("> ")
        parse_data(message)

And I have this code to run it concurrently

from multiprocessing import Process
if __name__ == "__main__":
    Process(target=ticker).start()
    Process(target=main).start()

I experience an EoF error in main() on input("> "). If I catch this error in a try / except like so:

try:
    message = input("> ")
except EOFError:
    continue

This will just continually print "> " to the screen. If I try it this way

try:
    message = input("> ")
except EOFError:
    main()

where main() is the function which contains this code, it'll just continually error.

There appears to be no errors in the ticker() function. The only errors appear to be coming from my lack of understanding of concurrency in Python and a lack of google-results for this query.

Thank you for your time.

Brandon Skerritt
  • 380
  • 2
  • 3
  • 12
  • Just put the loop that's in the main function under `if __name__ == "__main__":` rather than in its own function – ubadub Dec 30 '17 at 00:17

0 Answers0