[Numpy-discussion] Handling interrupts in NumPy extensions
oliphant.travis at ieee.org
Thu Aug 24 22:20:45 CDT 2006
David Cournapeau wrote:
>> If nothing is known about memory allocation of the external library,
>> then I don't see how it can be safely interrupted using any mechanism.
> If the library does nothing w.r.t signals, then you just have to clean
> all the things related to the library once
> you caught a signal. This is no different than cleaning your own code.
Right, as long as you know what to do you are O.K. I was just thinking
about a hypothetical situation where the library allocated some
temporary memory that it was going to free at the end of the subroutine
but then an interrupt jumped out back to your code before it could
finish. In a case like this, you would have to use the "check if
interrupt has occurred" approach before and after the library call.
But, then that library call is not interruptable. I could also see
wanting to be able to interrupt a library calculation when you know it
isn't allocating memory. So, I like having both possibilities available.
So far we haven't actually put anything in the numpy code itself. I'm
leaning to putting PyOS_InterruptOccurred-style checks in a few places
at some point down the road.
More information about the Numpy-discussion