[pypy-svn] r29132 - pypy/dist/pypy/lib
mwh at codespeak.net
mwh at codespeak.net
Thu Jun 22 14:38:04 CEST 2006
Author: mwh
Date: Thu Jun 22 14:38:03 2006
New Revision: 29132
Modified:
pypy/dist/pypy/lib/stackless.py
Log:
hacks towards tasklet pickling
Modified: pypy/dist/pypy/lib/stackless.py
==============================================================================
--- pypy/dist/pypy/lib/stackless.py (original)
+++ pypy/dist/pypy/lib/stackless.py Thu Jun 22 14:38:03 2006
@@ -54,6 +54,9 @@
#sys.excepthook(etype, value, stack)
raise etype(value)
+def _return_main():
+ return main_tasklet
+
class TaskletProxy(object):
def __init__(self, coro):
self.alive = True
@@ -79,6 +82,9 @@
def __getattr__(self,attr):
return getattr(self._coro,attr)
+ def __reduce__(self):
+ return _return_main, ()
+
class bomb(object):
"""
A bomb object is used to hold exceptions in tasklets.
@@ -429,6 +435,16 @@
self.alive = True
self.insert()
+ def __reduce__(self):
+ one, two, three = coroutine.__reduce__(self)
+ assert one is coroutine
+ assert two == ()
+ return tasklet, (), (three, self.tempval)
+
+ def __setstate__(self, (coro_state, tempval)):
+ coroutine.__setstate__(self, coro_state)
+ self.tempval = tempval
+
def channel_callback(chan, task, sending, willblock):
return channel_hook(chan, task, sending, willblock)
@@ -811,6 +827,13 @@
else:
return -1
+ def __reduce__(self):
+ if self is scheduler:
+ return _return_sched, (), ()
+
+def _return_sched():
+ return scheduler
+
def __init():
global main_tasklet
global main_coroutine
More information about the Pypy-commit
mailing list