[pypy-commit] pypy stacklet: Attach 'parent' even if __init__ is not called, e.g. because
arigo
noreply at buildbot.pypy.org
Sat Aug 20 11:18:27 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: stacklet
Changeset: r46662:117a9856f981
Date: 2011-08-20 11:22 +0200
http://bitbucket.org/pypy/pypy/changeset/117a9856f981/
Log: Attach 'parent' even if __init__ is not called, e.g. because it was
overridden and the parent __init__ is ignored.
diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -34,12 +34,16 @@
__main = False
__started = False
+ def __new__(cls, *args, **kwds):
+ self = _continulet.__new__(cls)
+ self.parent = getcurrent()
+ return self
+
def __init__(self, run=None, parent=None):
if run is not None:
self.run = run
- if parent is None:
- parent = getcurrent()
- self.parent = parent
+ if parent is not None:
+ self.parent = parent
def switch(self, *args):
"Switch execution to this greenlet, optionally passing the values "
@@ -116,10 +120,11 @@
def _green_create_main():
# create the main greenlet for this thread
+ _tls.current = None
gmain = greenlet.__new__(greenlet)
gmain._greenlet__main = True
gmain._greenlet__started = True
- gmain.parent = None
+ assert gmain.parent is None
_tls.main = gmain
_tls.current = gmain
More information about the pypy-commit
mailing list