[Numpy-discussion] Handling interrupts in NumPy extensions
David M. Cooke
cookedm at physics.mcmaster.ca
Thu Aug 24 18:40:55 CDT 2006
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;
}
(where interrupted is a static int).
--
|>|\/|<
/------------------------------------------------------------------\
|David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca
More information about the Numpy-discussion
mailing list