[Stackless] Debugging stackless applications
Andrew Francis
andrewfr_ice at yahoo.com
Wed Aug 15 18:47:00 CEST 2007
Hello Rotem:
Darn, I have to stop getting digests...
>for instance:
>
>def g(some_param):
> if some_param % 2 == 0:
> raise Exception()
I don't quite understand why you are importing pdb in
the exception. You are also catching your exception in
the wrong place. Finally I believe if main exits, then
there will be one tasklet running and Stackless will
terminate. I re-wrote the code.
#!/usr/bin/env python
import stackless
import pdb
def g(some_param):
if some_param % 2 == 0:
#pdb.set_trace()
print "=>", some_param
raise Exception()
def f(some_param, name):
print name,"starting"
stackless.schedule()
g(some_param)
stackless.schedule()
print name, "finished"
task1 = stackless.tasklet(f)(1, "task1")
task2 = stackless.tasklet(f)(2, "task2")
try:
stackless.run()
except Exception:
print "An exception was thrown"
# make sure, main thread doesn't exit just yet
while stackless.getruncount() > 1:
stackless.schedule()
and I get:
task1 starting
task2 starting
=> 2
An exception was thrown
task1 finished
If you uncomment the pdb.set_trace, you can step
through task2. I guess this approach is better than
nothing.
Cheers,
Andrew
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://stackless.com/cgi-bin/mailman/listinfo/stackless
More information about the Stackless
mailing list