[Numpy-svn] r3062 - trunk/numpy/core/src

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Aug 24 17:40:05 CDT 2006


Author: oliphant
Date: 2006-08-24 17:39:57 -0500 (Thu, 24 Aug 2006)
New Revision: 3062

Modified:
   trunk/numpy/core/src/multiarraymodule.c
Log:
Add an example of using PyOS_InterruptOccurred() to the test_interuppt function.

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-08-24 20:07:59 UTC (rev 3061)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-08-24 22:39:57 UTC (rev 3062)
@@ -6431,16 +6431,30 @@
 
 
 static PyObject *
-test_interrupt(PyObject *self)
+test_interrupt(PyObject *self, PyObject *args)
 {
+        int kind=0;
         int a = 0;
-        NPY_SIGINT_ON
 
-        while(a>=0) {
-            a += 1;
+        if (!PyArg_ParseTuple(args, "|i", &kind)) return NULL;
+
+        if (kind) {
+                while (a>=0) {
+                        if ((a % 1000 == 0) &&
+                            PyOS_InterruptOccurred()) break;
+                        a+=1;
+                }
         }
+        else {
 
-        NPY_SIGINT_OFF
+                NPY_SIGINT_ON
+                        
+                while(a>=0) {
+                        a += 1;
+                }
+                
+                NPY_SIGINT_OFF                        
+        }
             
         return PyInt_FromLong(a);
 }
@@ -6500,7 +6514,7 @@
         {"compare_chararrays", (PyCFunction)compare_chararrays,
          METH_VARARGS | METH_KEYWORDS, NULL},
         {"test_interrupt", (PyCFunction)test_interrupt,
-         METH_NOARGS, NULL},
+         METH_VARARGS, NULL},
 	{NULL,		NULL, 0}		/* sentinel */
 };
 



More information about the Numpy-svn mailing list