Author: Armin Rigo <[email protected]>
Branch: stacklet
Changeset: r46639:12c0e7ccb36b
Date: 2011-08-19 15:10 +0200
http://bitbucket.org/pypy/pypy/changeset/12c0e7ccb36b/
Log: Test and implementation for GreenletExit.
diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -49,9 +49,8 @@
args = None
target.__started = True
else:
- # already done, go to main instead
- xxxx
- target = _tls.main
+ # already done, go to main instead... xxx later
+ raise error("greenlet execution already finished")
#
try:
if current.__main:
@@ -68,6 +67,8 @@
else:
# switch from non-main to non-main
args = _continulet.switch(current, args, to=target)
+ except GreenletExit, e:
+ args = (e,)
finally:
_tls.current = current
#
diff --git a/pypy/module/test_lib_pypy/test_greenlet.py
b/pypy/module/test_lib_pypy/test_greenlet.py
--- a/pypy/module/test_lib_pypy/test_greenlet.py
+++ b/pypy/module/test_lib_pypy/test_greenlet.py
@@ -64,3 +64,13 @@
assert not g1 and not g1.dead
g1.switch()
assert not g1 and g1.dead
+
+ def test_GreenletExit(self):
+ from greenlet import greenlet, GreenletExit
+ #
+ def fmain(*args):
+ raise GreenletExit(*args)
+ #
+ g1 = greenlet(fmain)
+ res = g1.switch('foo', 'bar')
+ assert isinstance(res, GreenletExit) and res.args == ('foo', 'bar')
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit