[Stackless] Questions about Tasklets and Callbacks

Christian Tismer tismer at stackless.com
Tue Apr 10 00:27:42 CEST 2007


How!

On 09.04.2007, at 23:08, Andrew Francis wrote:

> Hi Colleagues:
>
> I trying to understand how to better integrate Twisted
> with Stackless. I realise that I do not understand
> what is happening under the hood in the Stackless
> Python VM.
>
> I have some simple questions. When a callback is
> activated, what is its relationship to Stackless? Is
> it running as a part of the main tasklet? Also is it
> safe for a callback to issue a channel.receive? Under
> what conditions will this fail?

There is always one and only one tasklet running.
The only running tasklet is always found as stackless.current.
It does not matter which function of a callback or whatever
is running. There is no relationship between functions
and tasklet but the fact that a tasklet is started with a
given function bound to it, or even with the main tasklet,
just whatever code that is running as main.

What belongs to the tasklet that you just left by a jump,
using schedule() or a channel method, is only determined
by the fact that you just jumped away from it. The piece
of the past that you just left by the jump is now the frozen
state of that tasklet, no matter what code this was.
You now active current represents the future of your
program and does whatever you want it to do as this
current tasklet, until you leave it again in the past
when you are switching to something else.

So in other words, all the traces of your code are divided
into disjoint chunks, determined by when you jump.
This is a partition of your program's past, and each tasklet
is a bin that represents all the execution path pieces
when this tasklet was assigned to current.

This is all about it.

cheers - chris


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



More information about the Stackless mailing list