[pypy-svn] r34322 - in pypy/dist/pypy: lib module/_stackless/test

arigo at codespeak.net arigo at codespeak.net
Tue Nov 7 13:44:17 CET 2006


Author: arigo
Date: Tue Nov  7 13:44:12 2006
New Revision: 34322

Modified:
   pypy/dist/pypy/lib/stackless.py
   pypy/dist/pypy/module/_stackless/test/test_coroutine.py
Log:
Another (skipped) test about kill(), which is not working in app-level
coroutines because the interp-level code only knows about a special
interp-level CoroutineExit exception which is not visible at app-level.
Not sure how to fix it.



Modified: pypy/dist/pypy/lib/stackless.py
==============================================================================
--- pypy/dist/pypy/lib/stackless.py	(original)
+++ pypy/dist/pypy/lib/stackless.py	Tue Nov  7 13:44:12 2006
@@ -353,7 +353,7 @@
         """
         if not self.is_zombie:
             coroutine.kill(self)
-        return self.raise_excption(TaskletExit)
+        return self.raise_exception(TaskletExit, TaskletExit())
 
     def raise_exception(self, exc, value):
         """

Modified: pypy/dist/pypy/module/_stackless/test/test_coroutine.py
==============================================================================
--- pypy/dist/pypy/module/_stackless/test/test_coroutine.py	(original)
+++ pypy/dist/pypy/module/_stackless/test/test_coroutine.py	Tue Nov  7 13:44:12 2006
@@ -85,6 +85,31 @@
         co.kill()
         assert not co.is_alive
 
+    def test_kill_running(self):
+        skip("kill is not really working (there is only CoroutineExit, "
+             "which is not an app-level exception)")
+        import _stackless as stackless
+        main = stackless.coroutine.getcurrent()
+        result = []
+        co = stackless.coroutine()
+        def f():
+            x = 2
+            try:
+                result.append(1)
+                main.switch()
+                x = 3
+            finally:
+                result.append(x)
+            result.append(4)
+        co.bind(f)
+        assert co.is_alive
+        co.switch()
+        assert co.is_alive
+        assert result == [1]
+        co.kill()
+        assert not co.is_alive
+        assert result == [1, 2]
+
     def test_bogus_bind(self):
         import _stackless as stackless
         co = stackless.coroutine()



More information about the Pypy-commit mailing list