[Stackless] Starting in stackless...

Carlos Eduardo de Paula cedepaula at yahoo.com.br
Wed Mar 22 19:18:09 CET 2006


Hello,

I just subscribed in the list.. I´m starting up in
stackless and haven´t done much things with
multithread so i´m a little confused. 

I created a little program to test the
producer/consumer chain.. but with no success... maybe
someone could give me a hint about how to make it
work... or point some documentation about it...

----------------

import stackless
import time

q_size = 15
queue = []
ch_p = stackless.channel()
ch_c = stackless.channel()

print ""

def producer():
    while True:
        if (len(queue) < q_size):
            queue.append("a")
            print "P[" + "#" * len(queue) + " " *
(15-len(queue))  + "]" + "\r",
            time.sleep(0.3)
            stackless.schedule()
        else:
            ch_c.send(None)    	
            ch_p.receive()


def consumer():
    while True:
        if (len(queue) >= 1):
            queue.pop()
            print "C[" + "#" * len(queue) + " " *
(15-len(queue))  + "]" + "\r",
            time.sleep(0.9)
            stackless.schedule()
        else:
            ch_p.send(None)
            ch_c.receive()

prod = stackless.tasklet(producer)
cons = stackless.tasklet(consumer)

stackless.run()


----------------


Thanks for all,

Carlos


	



	
		
_______________________________________________________ 
Yahoo! doce lar. Faça do Yahoo! sua homepage. 
http://br.yahoo.com/homepageset.html 


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



More information about the Stackless mailing list