[Numpy-discussion] KeyboardInterrupt shows strange behavior

Norbert Nemec Norbert.Nemec.list at gmx.de
Thu Nov 18 07:10:02 EST 2004


Hi there,

I have the following dummy code, doing garbage until I interrupt it:

------------------------------------
from numarray import *

A = zeros((100,100))
try:
    while 1:
        A = dot(A,A)
except KeyboardInterrupt:
    print "Interrupted"
--------------------------------------

Now, if I hit Ctrl-C to interrupt it, it behaves strangely. Most of the 
time, I see a message:

--------------------
Exception exceptions.KeyboardInterrupt in <bound method NumArray.__del__ 
of array([[0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       ...,
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0]])> ignored
-------------------------

after which the program continues to run, unimpressed by the fact that I 
would have liked to stop it.

Only one out of ten attempts of pressing Ctrl-C is successful (probably 
depending on the exact position in the code where I hit the keys) - but 
even then, the program does not quit cleanly with an exception but it 
crashes hard with a SegFault!

I am using a self-compiled glibc including the patch by Andrew Straw 
(see 
http://aspn.activestate.com/ASPN/Mail/Message/numpy-discussion/2207861) 
Might it be that this patch causes the problem?

Ciao,
Nobbi





More information about the NumPy-Discussion mailing list