[Stackless] Stackless and tracing (for debugger)

Harry Kalogirou harkal at sylphis3d.com
Wed Apr 26 23:31:39 CEST 2006


On Wed, 2006-04-26 at 17:06 +0000, Richard wrote:
> Wrap all callables that are put into tasklets so when they are first
> executed, your code will get executed first, installing the tracefunc.
> 
> >>> import stackless
> >>> tasklet = stackless.tasklet
> >>> def new_call(self, *args, **kwargs):
> ...     f = self.tempval
> ...     def new_f(old_f, args, kwargs):
> ...         print "wrapper.start", args, kwargs
> ...         old_f(*args, **kwargs)
> ...         print "wrapper.end"
> ...     self.tempval = new_f
> ...     tasklet.setup(self, f, args, kwargs)
> ...
> >>> tasklet.__call__ = new_call
> >>>
> >>> def test(*args, **kwargs):
> ...     print "test.enter", args, kwargs
> ...     stackless.schedule()
> ...     print "test.exit"
> ...
> >>> tasklet(test)(1,2,3, x=1, y=2, z=3)
> >>> stackless.run()
> wrapper.start (1, 2, 3) {'y': 2, 'x': 1, 'z': 3}
> test.enter (1, 2, 3) {'y': 2, 'x': 1, 'z': 3}
> test.exit
> wrapper.end
> >>>
> 
> This is how I would do it anyway.  But I imagine you are going to
> be doing it in C++.
> 
> Hope this helps,
> Richard.

So trace is per tasklet in Stackless. Good. When I was asking you about
the wrap thing I was actualy refering to the code that goes in the
wrapper :), not the wrapping procedure itself. To set the tracefunc per
thread we use sys.settrace() I suppose that there is something for
tasklets too. Now that I know that it is for sure a per tasklet matter I
will look in to it!

Thank you very much Richard!

Best regards,
Harry Kalogirou
http://harkal.sylphis3d.com



_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list