Threads - Newbie Questions

David Lees DavidL at NONOraqiaMAPS.com
Wed Dec 20 14:42:41 EST 2000


I am now starting to play with Python threads.  Could someone refer me
to documentation other than the Library reference for some simple
examples?

My specific questions are:
1. I am passing the lock as an argument to each thread.  Is this the
proper way to do it?

2. What is the 'kwargs' - optional keyword arguments refered to in the
Library Reference for start_new_thread?

Python is definitely cool.  I am starting to get the hang of it, with a
lot of help from this group.

Thanks in advance.

david lees

Here is my initial code:

import time, thread

def TestProcess(x,n,lk):
    print 'Process %d is starting' % n
    #time.sleep(1)
    lk.acquire()
    print 'Acquired process %d ' % n
    lk.release()
    
lx=thread.allocate_lock()
lx.acquire()

for i in range(100):
    thread.start_new(TestProcess,(0,i,lx))

time.sleep(3)

print 'Threads started, about to release lock'
lx.release()



More information about the Python-list mailing list