[Stackless] Mistakes, Corrections and Questions Concerning My Pickle Example Re: cPickleshould work?

Richard richard at ccpgames.com
Tue May 9 11:25:54 CEST 2006


> From Andrew Francis on 08 May 2006 18:38
> >The problem is the order in which the tasklets and
> >their channels are unpickled and restored with their
> >old state. Where restored is taken to mean setstate
> >called on them.
> 
> ...
> 
> Thanks for the detailed explanation for explaining why
> the code crashes. I am still going through your
> response to get a feel for what is happening. I
> thought about what you said.

Hi Andrew,

Well, what I said was more to explain the reason for the
crash and why it was happening, so that hopefully
someone could chime in with an opinion on whether the
fix I proposed was the correct one.  In any case, after
some thought I am confident that the fix suffices to fix
the unpickling bug so it has been checked in.

> I have included a solution that works. I can't seem to
> figure out a way of packaging channel information in
> such a way that I can get it from an unpickled task.
> Subsequently I pickle channels seperately.

I am not sure I understand.

Are you implying that the unpickled 'tasklets' list
contains the tasklets that are waiting on the channels
in the 'channels' list?  That is, the same unpickled
instances?

What exactly do you need to get here?

> An additional feature I want is the ability of the
> "scheduler" to pickle and unpickle an individual
> "process" blocked on a channel.

Isn't this what the 'tasklets' list gives you?  Unpickled
instances of the tasklets which are blocked on the
channels.  They are blocked where they were on the channels
they were waiting on, but not linked to a channel in
any way.

Of course, there is no way to get it back onto a channel
that I can think of offhand.  And there seems to be another
crash bug here which I will look into later.

i.e. tasklets[0].run()
 
> >From what I have seen, I can pickle and unpickle
> tasklets blocked on channels. So in this regard, I am
> happy.
> 
> However having a scheduler that is maintaining
> tasklets and channels, pickle and unpickle an
> individual tasklets is more difficult. Reason: I
> cannot do a tasklet.remove() on a blocked tasklet. Is
> there something I am missing. 

I also missed this ability when I was playing around with
channels some time ago (not pickling).  But pickling the
tasklet without any reference to the channel it is blocked
on, will give you a tasklet which has been removed in this
manner, as I understand it.

>>> print tasklets[0]._channel
None
>>> print tasklets[0].blocked
False

The ability to remove tasklets from channels, in the manner
that .remove removes them from the scheduler, seems like a
useful feature to add.  And the ability to add them back in,
as well.  If Christian is OK with it, I can add that.

Richard.

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



More information about the Stackless mailing list