How to kill Python interpreter from the command line?

spectrumdt at gmail.com spectrumdt at gmail.com
Fri May 9 06:19:03 EDT 2008


Thanks for the replies.

On May 8, 5:50 pm, Jean-Paul Calderone <exar... at divmod.com> wrote:
> Ctrl+C often works with Python, but as with any language, it's possible
> to write a program which will not respond to it.  You can use Ctrl+\
> instead (Ctrl+C sends SIGINT which can be masked or otherwise ignored,
> Ctrl+\ sends SIGQUIT which typically isn't)

Yes, thank you, this seems to work. :)

I did some more testing and found out that the problem seems to be
thread-related. If I have a single-threaded program, then Ctrl+C
usually works, but if I have threads, it is usually ignored. For
instance, the below program does not respond to Ctrl+C (but it does
die when issued Ctrl+\):



import threading

def loop():
  while True:
    pass

threading.Thread(target=loop,args=()).start()



More information about the Python-list mailing list