[Stackless] tracing stackless events

Christian Tismer tismer at stackless.com
Fri Dec 21 01:50:26 CET 2007

Andrew Dalke wrote:
> I've been experimenting with how to trace stackless events.  The ones 
> I'm most interested in are tasklet creation and destruction, context 
> switches between tasklets, and channel send/receive.
> With clues from the mailing list archive I found set_channel_callback 
> and set_schedule_callback.  These do most, but not everything I want.
> Some things I noticed:
>   - there's no way to know when a tasklet was created.  I worked around 
> it by reaching into the stackless module and wrapping 'tasklet'.
>   - the documentation for set_schedule_callback says the callback takes
>     two arguments, (prev, next)
>          When a tasklet is dying, next is None.
>      I never got a callback for this case.  My workaround will be to use 
> the weak reference notification event to watch the tasklet.
>   - the code for calling the channel callback silently swallows any 
> exceptions raised during the callback.  It should at least dump the 
> traceback to stderr.

Well, this was designed for debugging the application, not buggy
debugging code. But well, could be done.

>   - I would like to assign a name and perhaps a group name or other 
> properties to the tasklet and channel.  That makes it easier to debug.  
> But they are C types and I can't.  I had to use a weak dictionary instead.

I agree that this is hard for the main tasklet, which will be your
own creation in another future release.
But then, why are you not using inheritance, this is exactly what
it is meant for.

Christian Tismer             :^)   <mailto:tismer at stackless.com>
tismerysoft GmbH             :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
       whom do you want to sponsor today?   http://www.stackless.com/

More information about the Stackless mailing list