No threading.start_new_thread(), useful addition?
gandalf at shopzeus.com
Fri Oct 9 18:06:03 CEST 2009
> I personally find it much cleaner this way. Also, why should any code care
> in which thread it is executed? Why should I have to derive a class from
> some other only because I want to run one of its functions in a separate
I think you are right! Especially that you can (and probably will) call
other methods from your thread. For example, functions from the standard
library. Or use methods of objects that where created in a different
thread. I think we can say, you must call methods of other (not Thread)
objects if you ever want to do something useful in your thread.
Now I'm beginnig to agree with you, Ulrich. We have
threading.enumerate() - it can be used to list active threads. So if you
only want to start a function in a separate thread, then you do not
really need the Thread object. Then we do you HAVE TO create a Thread
Of course you can easily create a nice decorator like this:
thr = threading.Thread(target=func,args=args,kwargs=kwargs)
And then do something like:
print "please wait..."
thr = print_something(3,"Test")
print "started print_something in",thr
How about that? (Or was it your concern that it is not part of the
More information about the Python-list