Hi Chris:
On Sat, Jul 11, 2009 at 6:53 PM, Chris Jacobson<[email protected]> wrote:
> I can think of at least one situation when this could occur, involving
> Channel Preference of 1 (Sender):
>
> Channel N is created with preference 1
> Tasklet?A and?B start
> Tasklet A runs, receives on N, and blocks
> Tasklet?B sees N has balance -1, so sends to N.? Due to Preference, B will
> not yield, instead?A is placed at end of runnables queue.? The channel's
> balance is now 0.
> Tasklet?B continues running, sees N has a balance of 0, so does not send.
> Repeat ad infinitum.? Tasklet?B never explicitly schedules or gets blocked
> otherwise, and so?A never wakes up.
Well one can create pathological cases. In regard to channels, pathological
probably depends on inconsistently using the balance variable and the
send()/receive() methods. In the example you stated, everything revolves around
what "sees N has a a balance of 0, so does not send." What does "sees" mean?
If b is in a loop and "sees" via a send(), then what happens is the second
time, b blocks on a send() [which should have a balance of 0], the programme
ends rather continues ad infiniuum. Why? All tasklets are now blocked.
Try it:
import stackless
def a(ch):
message = ch.receive()
print message
def b(ch):
while(1):
print ch.balance
ch.send("foo")
if __name__ == "__main__":
ch = stackless.channel()
ch.preference = 1
stackless.tasklet(a)(ch)
stackless.tasklet(b)(ch)
stackless.run()
In regards to Paul's problem. Posting code would be nice. However I have found
that the more I use Stackless, the less I write code that looks at the
channel.balance to make a scheduling decision.
Cheers,
Andrew
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless