this is all very confusing, but I'll do my best.
The fun stuff is happening in interp_coroutine.py
which looks at the moment like this:
--------------------------------------------------------------
def _execute(self, incoming_frame):
syncstate.switched(incoming_frame)
state = self.costate
try:
try:
self.thunk.call()
finally:
self.finished()
self.thunk = None
resume_point("coroutine__bind", self, state)
except CoroutineExit:
# ignore a shutdown exception
pass
except Exception, e:
# redirect all unhandled exceptions to the parent
syncstate.things_to_do = True
syncstate.temp_exc = e
while self.parent is not None and self.parent.frame is None:
# greenlet behavior is fine
self.parent = self.parent.parent
return state.update(self.parent)
-------------------------------------------
I've inserted the 'self.finished()' hook yesterday, to give applevel
coroutines (in this case tasklets) the chance to do their last rites.
Specifically, I needed that so that the stackless scheduler has a chance
to stay in sync.
Now, the tasklet.finished method contains a 'schedule'. What happens is
that the Exception handling in _execute above is ignored. Bad.
As a next test, I've moved the 'self.finished()' call right before the
return. This certainly gives the exception handling a chance to do it's
thing and the stackless code still does it things.
But now I get the following error message from py.py:
Traceback (most recent call last):
File "/usr/local/bin/py.py", line 207, in ?
sys.exit(main_(sys.argv))
File "/usr/local/bin/py.py", line 118, in main_
if not main.run_toplevel(space, doit, verbose=Options.verbose):
File "/home/stephan/projects/pypy-dist/pypy/interpreter/main.py",
line 80, in run_toplevel
f()
File "/usr/local/bin/py.py", line 105, in doit
main.run_file(args[0], space=space)
File "/home/stephan/projects/pypy-dist/pypy/interpreter/main.py",
line 67, in run_file
run_string(istring, filename, space)
File "/home/stephan/projects/pypy-dist/pypy/interpreter/main.py",
line 58, in run_string
_run_eval_string(source, filename, space, False)
File "/home/stephan/projects/pypy-dist/pypy/interpreter/main.py",
line 47, in _run_eval_string
retval = pycode.exec_code(space, w_globals, w_globals)
File "/home/stephan/projects/pypy-dist/pypy/interpreter/eval.py",
line 26, in exec_code
return frame.run()
File "/home/stephan/projects/pypy-dist/pypy/interpreter/eval.py",
line 162, in resume
executioncontext.leave(self)
File
"/home/stephan/projects/pypy-dist/pypy/interpreter/executioncontext.py",
line 38, in leave
self.framestack.pop()
File
"/home/stephan/projects/pypy-dist/pypy/interpreter/miscutils.py", line
34, in pop
return self.items.pop()
IndexError: pop from empty list
----------------------------------------------------
So, somehow I either have nice stackless scheduler clean up code, or I
have proper exception handling.
If somebody has a nice idea what to do, I'd be very happy to hear about
that.
Cheers
Stephan
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev