Chironex
Chironex

Reputation: 413

KeyboardInterrupt unpredictable in Python 2.7 under ipython, how can I make it *always* abort current evaluation?

I'm writing python code to do numerical analysis, and I've been using ipython or ipython -pylab as my command line interface. I often run into situations where some code is taking for-freaking-ever to run, and I need to stop it. However, Ctrl-C is problematic; sometimes it works, sometimes it doesn't do anything, and sometimes it quits the whole process (very annoying.) How can I make it so that hitting Ctrl-C always always works? It seems as if the times that it doesn't work are those where it is executing code in some other module.

Thanks much.

Upvotes: 2

Views: 989

Answers (1)

Florian Mayer
Florian Mayer

Reputation: 3081

You are probably running a background thread that is swallowing the signal, there is no real way of prohibiting that, compare http://www.dabeaz.com/python/GIL.pdf

Upvotes: 1

Related Questions