No threading.start_new_thread(), useful addition?

Hendrik van Rooyen hendrik at microcorp.co.za
Thu Oct 8 11:16:39 EDT 2009


On Thursday, 8 October 2009 13:24:14 Christian Heimes wrote:
> Laszlo Nagy wrote:
> > But really thread.start_new_thread is better:
> >
> > import thread.start_new_thread as thr
> >
> > thr(my_function,arg1,arg2)
>
> Please don't use the thread module directly, especially the
> start_new_thread function. It a low level function that bypasses the
> threading framework. The is no good reason to use this function in favor
> of threading.Thread().

I have seen this advice a couple of times now, and I do not understand it.

From my perspective (which is admittedly jaundiced) Threading just adds a 
bunch of superfluous stuff like a run method and other weird things that I 
cannot see a need for.

The simplicity of this kind of code:

def this_is_a_thread(arg1,arg2):
    do_some_initialisation(arg1,arg2)
    while some_condition:
        do_some_stuff()

which then gets started with thread.start_new_thread, does it for me.

What does the Threading module buy me, other than a formal OO approach?

- Hendrik






More information about the Python-list mailing list