0

I'm trying out threading in Python, and I found this answer with an example: https://stackoverflow.com/a/53344690/6252186 . When I run this code in an IPython console, it works as it is supposed for the first time, but the second time the prompt "ready for keyboard input" does not appear, and I can only get it running again if I restart the terminal / kernel.

In a (interactive) Python console, it works the first time, but when I type "exit", it prints "End" but I don't come back to the terminal prompt and am stuck with a blinking cursor.

What's going wrong and why are Python and IPython behaving differently?

LimaKilo
  • 196
  • 9
  • There are known issues with multiprocessing and ipython e.g. https://github.com/ipython/ipython/issues/10894. – Tom Dalton Sep 23 '19 at 10:35
  • @TomDalton If that is the only issue, shouldn't it work in the regular python console at least? – LimaKilo Sep 23 '19 at 14:31
  • Your process (program) won't exit while there are still threads running. The linked code contains a keyboard handling thread that never exits, it just goes round the loop forever. Hence the process never terminates – Tom Dalton Sep 23 '19 at 23:45
  • @TomDalton The code contains a break statement in the main loop if "exit" is typed, and the thread is set as a daemon to end when the rest ends. Is that not enough? – LimaKilo Sep 24 '19 at 07:36

0 Answers0