test for nogil functions
authorStefan Behnel <scoder@users.berlios.de>
Sat, 19 Jul 2008 09:06:41 +0000 (11:06 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 19 Jul 2008 09:06:41 +0000 (11:06 +0200)
tests/run/nogil.pyx [new file with mode: 0644]

diff --git a/tests/run/nogil.pyx b/tests/run/nogil.pyx
new file mode 100644 (file)
index 0000000..2671b9a
--- /dev/null
@@ -0,0 +1,22 @@
+__doc__ = u"""
+>>> test(5)
+89
+>>> test(11)
+95
+"""
+
+def test(int x):
+    with nogil:
+        f(x)
+        x = g(x)
+    return x
+
+cdef void f(int x) nogil:
+        cdef int y
+        y = x + 42
+        g(y)
+
+cdef int g(int x) nogil:
+        cdef int y
+        y = x + 42
+        return y