David M. Cooke wrote: >On Aug 24, 2006, at 18:38 , Travis Oliphant wrote: > > > >>You can already use the approach suggested: >> >>if (PyOS_InterruptOccurred()) goto error >> >>to handle interrupts. The drawback of this approach is that the loop >>executes more slowly because a check for the interrupt occurs many >>times >>in the loop which costs time. >> >>The advantage is that it may work with threads (I'm not clear on >>whether >>or not PyOS_InterruptOccurred can be called without the GIL, though). >> >> > >It should be; it's pure C code: > >int >PyOS_InterruptOccurred(void) >{ > if (!interrupted) > return 0; > interrupted = 0; > return 1; >} > >
I tried to test this with threads using the following program and it doesn't seem to respond to interrupts. import threading import numpy.core.multiarray as ncm class mythread(threading.Thread): def run(self): print "Starting thread", self.getName() ncm.test_interrupt(1) print "Ending thread", self.getName() m1 = mythread() m2 = mythread() m1.start() m2.start() ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion