uthread4/9 MicroThreads

Chris Armstrong punck at PenguinMints.cx
Sun Oct 15 00:21:01 EDT 2000


Hey all. I'm working on a funky little queuing system for MicroThreads.
Anyway, my trouble is with the .start method of instances of 
uthread4.Thread. It seems to me that they're _supposed_ to actually
run the thread (that's what the comments in the code say), but
it seemingly does nothing. Here's the actual code for my queuing
system:

*****
import uthread4

def test1():
        print "hi1"
        print "hi2"

def test2():
        print "there1"
        print "there2"

queue = [(test1, []), (test2, []), (test1, []), (test2, [])]

sched = uthread4.Scheduler()

while 1:
        if len(sched.getAllThreads()) >= 50:
                sys.sleep(0.5)
                continue
        try:
                nextFunc = queue.pop(0)
                print "creating thread.."
                thread = uthread4.Thread("%s" % nextFunc[0], nextFunc[0], nextFu
                #thread.setResistant(1)
                print "starting thread..."
                thread.start(scheduler = sched)
        except: pass
*****

I also made a quick test just to see if the threading would work:
****
import uthread9

def test1():
        print "hi1"
        print "hi2"

def test2():
        print "there1"
        print "there2"

#sched = uthread9.Scheduler()


print "creating threads.."
thread = uthread9.Thread("test1", test1, [])
thread2 = uthread9.Thread("test2", test2, [])

print "starting threads..."
thread.start()
thread2.start()


****
The output is as follows:

creating threads..
starting threads...

I don't get it. Am I expecting the wrong things from .start()?
Thanks for any help.

-- 
Chris Armstrong        http://www.penguinmints.cx      punck at PenguinMints.cx
There is a 90% chance that this message was written when the author's been
awake longer than he should have. Please disregard any senseless drivel.



More information about the Python-list mailing list