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.

1
  • Just put the loop that's in the main function under if __name__ == "__main__": rather than in its own function Commented Dec 30, 2017 at 0:17

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.