Problems with threads and embedding

Jeff Epler jepler at unpythonic.net
Tue Jan 6 17:00:36 CET 2004


On my system, the attached script shows an expected behavior: at first
there are many threads running "daniel.py", then they slowly dwindle
back down to one.  Using slightly different flags to ps (it doesn't know
the "m" flag), I get identical results on redhat 6 (python 1.5.2) and
redhat 9 (python 2.2).

:r daniel.py
import thread, Queue, os
l = []
q = Queue.Queue(10)

def enqueue():
    os.system("ps mT")
    q.put(thread.get_ident())

for i in range(10):
    thread.start_new(enqueue, ())

for i in range(10):
    print q.get()

os.system("ps mT")

This suggests that the problem may be architecture-specific,
thread-library specific, or it may be due to some difference between
the normal python executable and the executable with embedded Python.

Jeff




More information about the Python-list mailing list