[Stackless] Scheduling Examples, Problems, Solutions, and Questions

Richard lickspittle at gmail.com
Wed Dec 14 09:45:45 CET 2005


On 12/13/05, Andrew Francis <andrewfr_ice at yahoo.com> wrote:
> This is wrong. I don't understand why the programme
> ends while
> tasklets still should be running.

Because there are no tasklets running, all are blocked on channels.  I
had this the other day, and for the life of me I could not work out
why it was exiting.  I even had tasklets wrapped in a function that
caught exceptions and that didn't show me the problem.

def MollycoddledTasklet(f, *args, **kwargs):
    try:
        f(*args, **kwargs)
    except:
        traceback.print_exc()

stackless.tasklet(MollycoddledTasklet, f, ...)

As python exited after stackless.run() executed, TaskletExit was
raised on every blocked tasklet, except the last running tasklet which
had also called .receive(). There might be something to look into
there, whether that one is getting missed for TaskletExit being
raised.  Writing a simpler example, I was unable to reproduce it so I
didn't bother Christian about it.

> I think what is happening is when Activity B updates
> BtoC,
> B is scheduled to the end. When C reads "AtoC", it is
> rescheduled to the end of the list. However E should
> be in a position to re-activate B and C.

The Queue put method is non-blocking.

Your native use of the channel send method is blocking.

> print stackless.channel.send.__doc__
channel.send(value) -- send a value over the channel.
If no other tasklet is already receiving on the channel,
the sender will be blocked. Otherwise, the receiver will
be activated immediately, and the sender is put at the end of
the runnables list.
Note that an exception instance sent will be raised at the receiver
(see also channel.send_exception)

If you change the .send calls to a simple non-blocking form then your
code should run:

  stackless.tasklet(someChannel.send)(True)

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



More information about the Stackless mailing list