threading.start(): does it fork??

Theodore D. Sternberg strnbrg at onebox.com
Fri Jan 11 16:47:32 EST 2002


When Python starts a second thread, ps shows not one, not two but
three (!) python processes.  When the thread exits, there are still
two python processes.  This can't be normal.

Here's a simple example.

---------------- cut here --------------
import threading
import time

def threadFunc():
    while not done:
        time.sleep(0.2)

done = 0
my_thread = threading.Thread( group=None, target=threadFunc, args=() )
my_thread.start()

time.sleep(2)
done = 1
time.sleep(10000)
-------------------- cut here ---------------

I'm running Linux 2.2.16, and Python 2.1 built with gcc 2.95.3.
It makes no difference if I join the thread, or call exit() inside it.



More information about the Python-list mailing list