[Stackless] Q2: Uthread's 'Thread' class

Ixokai ixokai at myseraph.org
Thu Apr 12 08:55:32 CEST 2001

questions, it was very much helpful. :)

    In my last mail, no one answered my question regarding classes, and I
suspect that is because I didn't actually phrase it as a very good question

>From the microthread documentation: "When threads are created using the
Thread class, the first argument of the thread's function will be the thread

It gives sample code which basically is basically:

mythreads = []
def foo(instance, num):
    uninteresting_math = num * 2
    printw('<' + repr(instance) + ' ' + repr(num) + '>')

for n in range(100):
    t = uthread.Thread(foo, int(30 * uthread.random()))

etc. Now. I really don't see what's going on :) Looking into uthread.py's
source tells me that Thread's init method takes at least two arguments; a
function to call, a 'name' (???), and any args/kwargs you're going to pass
the function.

It appears as if you are not susposed to sub-class Thread, but instead just
instantiate a Thread class and pass it a function you wish it to call, and
any arguments you wish it to pass, in addition to the thread's own instance.
Am I reading that correctly?

Now the wall that I am hitting: we are passing in two arguments in the
sample code: a function, and a number to be an argument for that function.
What the heck is the 'name' susposed to be, and how is it not missing in the
above code?



Stackless mailing list
Stackless at starship.python.net

More information about the Stackless mailing list