Author: Armin Rigo <[email protected]>
Branch: stacklet
Changeset: r46637:513fb078cff7
Date: 2011-08-19 15:02 +0200
http://bitbucket.org/pypy/pypy/changeset/513fb078cff7/
Log: dead.
diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -78,23 +78,13 @@
def throw(self, typ=GreenletExit, val=None, tb=None):
"raise exception in greenlet, return value passed when switching back"
- if self.__state_dead():
- # dead greenlet: turn GreenletExit into a regular return
- if (isinstance(typ, type(GreenletExit)) and
- issubclass(typ, GreenletExit)):
- if val is None:
- return self.switch(typ())
- if isinstance(val, GreenletExit):
- return self.switch(val)
- if isinstance(typ, GreenletExit):
- return self.switch(typ)
- #
- _tls.passaround_exception = (typ, val, tb)
- return self.switch()
+ XXX
__nonzero__ = _continulet.is_pending
-## dead = property(__state_dead)
+ @property
+ def dead(self):
+ return self.__started and not self
@property
def parent(self):
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
@@ -53,3 +53,14 @@
#
g1 = greenlet(fmain)
raises(ValueError, g1.switch)
+
+ def test_dead(self):
+ from greenlet import greenlet
+ #
+ def fmain():
+ assert g1 and not g1.dead
+ #
+ g1 = greenlet(fmain)
+ assert not g1 and not g1.dead
+ g1.switch()
+ assert not g1 and g1.dead
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit