[pypy-svn] r64099 - in pypy/trunk/pypy/module/_stackless: . test

arigo at codespeak.net arigo at codespeak.net
Wed Apr 15 16:27:13 CEST 2009


Author: arigo
Date: Wed Apr 15 16:27:12 2009
New Revision: 64099

Modified:
   pypy/trunk/pypy/module/_stackless/__init__.py
   pypy/trunk/pypy/module/_stackless/interp_coroutine.py
   pypy/trunk/pypy/module/_stackless/test/test_coroutine.py
Log:
App-level interface to {set,get}_stack_depth_limit().
(translating pypy now to test...)


Modified: pypy/trunk/pypy/module/_stackless/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/_stackless/__init__.py	(original)
+++ pypy/trunk/pypy/module/_stackless/__init__.py	Wed Apr 15 16:27:12 2009
@@ -17,6 +17,8 @@
         'greenlet'   : 'interp_greenlet.AppGreenlet',
         'usercostate': 'interp_composable_coroutine.W_UserCoState',
         '_return_main' : 'interp_coroutine.return_main',
+        'get_stack_depth_limit': 'interp_coroutine.get_stack_depth_limit',
+        'set_stack_depth_limit': 'interp_coroutine.set_stack_depth_limit',
     }
 
     def setup_after_space_initialization(self):

Modified: pypy/trunk/pypy/module/_stackless/interp_coroutine.py
==============================================================================
--- pypy/trunk/pypy/module/_stackless/interp_coroutine.py	(original)
+++ pypy/trunk/pypy/module/_stackless/interp_coroutine.py	Wed Apr 15 16:27:12 2009
@@ -338,3 +338,11 @@
 def return_main(space):
     return AppCoroutine._get_state(space).main
 return_main.unwrap_spec = [ObjSpace]
+
+def get_stack_depth_limit(space):
+    return space.wrap(rstack.get_stack_depth_limit())
+get_stack_depth_limit.unwrap_spec = [ObjSpace]
+
+def set_stack_depth_limit(space, limit):
+    rstack.set_stack_depth_limit(limit)
+set_stack_depth_limit.unwrap_spec = [ObjSpace, int]

Modified: pypy/trunk/pypy/module/_stackless/test/test_coroutine.py
==============================================================================
--- pypy/trunk/pypy/module/_stackless/test/test_coroutine.py	(original)
+++ pypy/trunk/pypy/module/_stackless/test/test_coroutine.py	Wed Apr 15 16:27:12 2009
@@ -1,4 +1,4 @@
-from pypy.conftest import gettestobjspace
+from pypy.conftest import gettestobjspace, option
 from py.test import skip
 
 
@@ -115,3 +115,24 @@
             pass
         co.bind(f)
         raises(ValueError, co.bind, f)
+
+
+class AppTestDirect:
+    def setup_class(cls):
+        if not option.runappdirect:
+            skip('pure appdirect test (run with -A)')
+        cls.space = gettestobjspace(usemodules=('_stackless',))
+
+    def test_stack_depth_limit(self):
+        import _stackless as stackless
+        assert stackless.get_stack_depth_limit() == sys.maxint    # for now
+        stackless.set_stack_depth_limit(1)
+        assert stackless.get_stack_depth_limit() == 1
+        try:
+            co = stackless.coroutine()
+            def f():
+                pass
+            co.bind(f)
+            co.switch()
+        except RuntimeError:
+            pass



More information about the Pypy-commit mailing list