<div>This is an implementation for what amounts to a queue or buffered channel. Any suggestions, advice, criticism before I post this to the wiki would be appreciated. Its probably not the cleanest solution but at least it's pretty. Also anyone have any objections to me restoring the link to the channels page to the main stackless page?</div> <div> </div> <div> </div> <div>import stackless</div> <div>class Queue(stackless.channel):<BR> def uselesstasklet(self,value):<BR> return stackless.channel.send(self, value)<BR> def send(self, value, wait=False):<BR> useless = stackless.tasklet(self.uselesstasklet)(value)<BR> stackless.schedule(useless)<BR> return None<BR> </div> <div>def
testQueue():<BR> print<BR> print "testQueue"<BR> print "--------------------"<BR> def recv(ch, name):<BR> print "Started recv<%s>" % (name,)<BR> print "recv<%s>: %r" % (name, ch.receive())</div> <div> ch = Queue()</div> <div> # Queues are nonblocking on sends when there are no receivers<BR> ch.send("Primary Entry")<BR> ch.send("Secondary Entry")</div> <div> for name in "ABCD":<BR> task = stackless.tasklet(recv)(ch, name)<BR> task.run()</div> <div> ch.send("Third Entry")<BR> ch.send("Fourth Entry")<BR> print</div> <div>testQueue()</div> <div> </div> <div>Thanks guys.</div>
<div> </div> <div>Benjamin Buco</div> <div>MCSE:Security</div> <div>IT Instructor</div> <div>TechSkills Cincinnati</div><p>
                <hr size=1>Blab-away for as little as 1¢/min. Make <a href="http://us.rd.yahoo.com/mail_us/taglines/postman2/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com"> PC-to-Phone Calls</a> using Yahoo! Messenger with Voice.