10

I'm trying to do the exact same thing as this question:

How to prevent a block of code from being interrupted by KeyboardInterrupt in Python? (sorry, not enough rep yet to post this as a comment there)

However both of the top answers posted there aren't working for me. When I hit CTRL+C with either of those solutions in place, the script still closes immediately with:

forrtl: error (200): program aborting due to control-C event

The code I'm working on is fairly long and includes quite a few imported modules. Am I correct to assume one of these modules is interfering with the normal behavior of KeyboardInterrupt? If so, how can I figure out which one?

(I'm running python 2.7.6, 32bit on Windows)

thanks.

Community
  • 1
  • 1
tfg250
  • 376
  • 2
  • 10

1 Answers1

7

Scipy was causing the problem. The link below provides a solution, note that this is not unique to scipy.stats, but also occurs with other scipy functions.

Ctrl-C crashes Python after importing scipy.stats

Community
  • 1
  • 1
tfg250
  • 376
  • 2
  • 10
  • 4 weeks of debugging, now I learnt its the stupid from `scipy.signal import savgol_filter`. Found more elegant solution than the stuff in the link: just put the `scipy` import inside a function and that would make your `main` safe enogh. – Alex Deft Dec 09 '21 at 18:54