[Stackless] Beginner
Cristiano Paris
frodo at theshire.org
Tue May 30 16:28:25 CEST 2006
Cristiano Paris wrote:
> ...
> What if I wanted to run JUST the tasklet I called run() upon? That is,
> if theTasklet = t1, calling t1.run() (or whatever) should result in:
>
> Before theTasklet.run()
> A1
> After theTasklet.run()
> Before theTasklet.run()
> A2
> After theTasklet.run()
> Before theTasklet.run()
> A1
> After theTasklet.run()
> Before theTasklet.run()
> A2
> After theTasklet.run()
> ...
I've found a way to accomplish this. I removed all the tasklets from the
schedule queue. The code now looks like this:
------
import stackless as slp
def taskPrint(x):
while 1:
print x + "1"
slp.schedule()
print x + "2"
slp.schedule()
t1 = slp.tasklet(taskPrint)
t2 = slp.tasklet(taskPrint)
t3 = slp.tasklet(taskPrint)
t1.setup("A")
t2.setup("B")
t3.setup("C")
t1.remove()
t2.remove()
t3.remove()
theTasklet = t1
while 1:
print "Before theTasklet.run()"
theTasklet.run()
print "After theTasklet.run()"
------
Now, when I call run() on t1 I get the sequence A1/A2/A1/A2... is there
any other (possibly better) way to do it?
Cristiano
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless
More information about the Stackless
mailing list