[pypy-svn] r22802 - pypy/dist/pypy/module/stackless
tismer at codespeak.net
tismer at codespeak.net
Sat Jan 28 18:10:02 CET 2006
Author: tismer
Date: Sat Jan 28 18:10:00 2006
New Revision: 22802
Modified:
pypy/dist/pypy/module/stackless/interp_coroutine.py
Log:
there seems to be no need for something like a main coroutine
Modified: pypy/dist/pypy/module/stackless/interp_coroutine.py
==============================================================================
--- pypy/dist/pypy/module/stackless/interp_coroutine.py (original)
+++ pypy/dist/pypy/module/stackless/interp_coroutine.py Sat Jan 28 18:10:00 2006
@@ -14,7 +14,7 @@
class CoState(object):
def __init__(self):
- self.last = self.current = self.main = Coroutine()
+ self.last = self.current = Coroutine()
self.things_to_do = False
self.temp_exc = None
self.del_first = None
@@ -38,7 +38,7 @@
if costate is None:
self.parent = self
else:
- self.parent = costate.main
+ self.parent = costate.current
self.thunk = None
def bind(self, thunk):
@@ -82,7 +82,9 @@
_update_state = staticmethod(_update_state)
def kill(self):
- if costate.current is self:
+# if costate.current is self:
+ # raise CoroutineExit
+ if self.frame is None:
raise CoroutineExit
costate.things_to_do = True
costate.temp_exc = CoroutineExit()
@@ -118,10 +120,6 @@
return costate.current
get_current = staticmethod(get_current)
- def get_main():
- return costate.main
- get_main = staticmethod(get_main)
-
def check_for_zombie(self):
if costate.del_first is not None:
@@ -197,6 +195,7 @@
raise OperationError(space.w_ValueError, space.wrap(
"cannot bind a bound Coroutine"))
thunk = _AppThunk(space, w_func, __args__)
+ costate.current = appcostate.current
self.bind(thunk)
def w_switch(self):
@@ -204,6 +203,7 @@
if self.frame is None:
raise OperationError(space.w_ValueError, space.wrap(
"cannot switch to an unbound Coroutine"))
+ costate.current = appcostate.current
self.switch()
appcostate.current = self
ret, appcostate.tempval = appcostate.tempval, space.w_None
@@ -229,9 +229,6 @@
return space.wrap(appcostate.current)
get_current = staticmethod(get_current)
- def get_main(space):
- return space.wrap(appcostate.main)
- get_main = staticmethod(get_main)
# _mixin_ did not work
for methname in StacklessFlags.__dict__:
@@ -254,9 +251,8 @@
""")
def post_install(module):
- appcostate.main.space = module.space
+ appcostate.post_install(module.space)
makeStaticMethod(module, 'Coroutine', 'get_current')
- makeStaticMethod(module, 'Coroutine', 'get_main')
# space.appexec("""() :
@@ -270,12 +266,16 @@
kill = interp2app(AppCoroutine.w_kill),
is_zombie = GetSetProperty(AppCoroutine.w_get_is_zombie, doc=AppCoroutine.get_is_zombie.__doc__),
get_current = interp2app(AppCoroutine.get_current),
- get_main = interp2app(AppCoroutine.get_main),
)
class AppCoState(object):
def __init__(self):
- self.current = self.main = AppCoroutine()
+ self.current = AppCoroutine()
+
+ def post_install(self, space):
+ appcostate.current.space = space
+ appcostate.tempval = space.w_None
+
appcostate = AppCoState()
@@ -300,10 +300,4 @@
a new current. After a greenlet's switch, greenlet
gets a new current.
-This concept has a collision, because there is also
-some notation of a "main". The solution is to let
-every exposed class create its own main in advance.
-This is nice, because the different concepts
-can completely co-exist.
-
"""
\ No newline at end of file
More information about the Pypy-commit
mailing list