[Stackless] Debugging Tasklets

Kristján Valur Jónsson kristjan at ccpgames.com
Mon May 26 13:17:32 CEST 2008


sure, if t is your tasklet:
traceback.print_stack(t.frame)
or use
traceback.extract_stack(t.frame)
if you want to do other stuff with it.

K

> -----Original Message-----
> From: stackless-bounces at stackless.com [mailto:stackless-
> bounces at stackless.com] On Behalf Of Richard Tew
> Sent: Sunday, May 25, 2008 23:53
> To: Simon Pickles
> Cc: stackless mailing list
> Subject: Re: [Stackless] Debugging Tasklets
>
> On Sat, May 24, 2008 at 4:14 PM, Simon Pickles
> <sipickles at googlemail.com> wrote:
> > Richard Tew wrote:
> >> On Sat, May 24, 2008 at 8:53 AM, Simon Pickles
> <sipickles at googlemail.com> wrote:
> >> You could print a stacktrace of its call stack.
> >
> > I'd be interested in knowing how to do that....
>
> >>> import stackless
> >>> import traceback
> >>> def f():
> ...     while 1:
> ...             print "loop"
> ...             stackless.schedule()
> ...
> >>> def g():
> ...     try:
> ...             f()
> ...     except StandardError:
> ...             print "--- stacktrace of tasklet ---"
> ...             traceback.print_exc()
> ...             print "--- done ---"
> ...
> >>> t = stackless.tasklet(g)()
> >>> t.run()
> loop
> >>> t.raise_exception(StandardError, "test")
> --- stacktrace of tasklet ---
> Traceback (most recent call last):
>   File "<stdin>", line 3, in g
>   File "<stdin>", line 4, in f
> StandardError: test
> --- done ---
> >>>
>
> Whether it is possible to print a stacktrace of a non-current tasklet,
> I do not recall offhand and do not have the time to look into it at
> this time.
>
> Cheers,
> Richard.
>
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless





More information about the Stackless mailing list