[Stackless] Simple Threading Support
Paul Alvarez
palvarez at netenforcers.com
Fri Apr 11 21:32:52 CEST 2008
Hey everyone,
I've just recently stumbled upon the stackless module and
I'm very interested in its functionality. I have read quite a lot
regarding it on the wiki and have yet to discover a working solution to
my minor problem. I was hoping someone with more knowledge on stackless
would be able to give me a simple solution as I am sure I am probably
missing something obvious. I know this code is wrong as it is one of
many variations I've come up with, but I can't figure out what I am
doing wrong. Hopefully what I provide you will give you a good idea of
what I'm trying to get an understanding of. Just for the record, I am
using 2.5.2.
import stackless as s
results = (5,4,3,2,1)
def runMe(i):
time.sleep(i)
print "%d: Hello from TID %d" % (i,t.thread_id)
for i in results:
t = s.tasklet(runMe)(i)
s.run
As you can see what I had hoped to accomplish is to run
'time.sleep' a total of five times. I would assume that if it was
threading properly it would finish the final thread before the first
thread and supply unique thread IDs for each call.
Example, I want roughly:
1: Hello from TID 1956 /
2: Hello from TID 2466 |
3: Hello from TID 9347 |--Note various thread ID's, evidence it is
successfully threading
4: Hello from TID 4235 |
5: Hello from TID 5257 \
Instead of:
5: Hello from TID 1956 /
4: Hello from TID 1956 |
3: Hello from TID 1956 |-- Not very dynamic if you ask me
2: Hello from TID 1956 |
1: Hello from TID 1956 \
Thank you in advance for any references, advice, or example code.
-Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20080411/c8db73f2/attachment.htm>
More information about the Stackless
mailing list