[Stackless] Select() on channels?
Christian Tismer
tismer at stackless.com
Sat Sep 15 03:12:04 CEST 2007
Dear Arnar,
> On 9/14/07, Richard Tew <richard.m.tew at gmail.com> wrote:
> ...
>> def alt_select(*channels):
>> resultChannel = stackless.channel()
>> # See if anything is already waiting, and if so return it.
>> for c in channels:
>> if c.balance > 0:
>> return c.receive()
>
> If the alt_select is inside a loop and there's always something
> available on some channel, this will cause starvation of the channels
> that come after that one in the list. The CSP model calls for
> non-determinism here but with a condition that when multiple channels
> have available data, you should give them all an equal probability of
> being selected so in the long run they all get served.
>
>> tasklets = []
>> for inputChannel in channels:
>> tasklets.append(stackless.tasklet(alt_receiver)(resultChannel,
>> inputChannel))
>> firstTasklet, firstChannel, result = resultChannel.receive()
>> for tasklet in tasklets:
>> if tasklet is not firstTasklet:
>> tasklet.kill()
>> return firstChannel, result
Yes, this is true. The LIMBO model seems to assume a global
arbitrator for channels.
I'm very much apart from global structures, at all.
But I don't really understand Arnar's input right now.
Can you please formulate it, again? What is it exactly
what we're missing?
cheers -- chris
--
Christian Tismer :^) <mailto:tismer at stackless.com>
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
More information about the Stackless
mailing list