KeyboardInterrupt unpredictable in Python 2.7 unde

2019-07-17 08:42发布

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.

1条回答
等我变得足够好
2楼-- · 2019-07-17 08:57

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

查看更多
登录 后发表回答