<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<tt></tt> 
<br><tt>I am having the following output that I am a bit confused about.</tt>
<br><tt>setting other info to 'other info'</tt>
<br><tt>setting other info to 'other info'</tt>
<br><tt>Traceback (innermost last):</tt>
<br><tt>  File "D:\usr\karl\inproc\threadTest2.py", line 38, in ?</tt>
<br><tt>    TestThreads(2)</tt>
<br><tt>  File "D:\usr\karl\inproc\threadTest2.py", line 31, in TestThreads</tt>
<br><tt>    thread.start()</tt>
<br><tt>  File "d:\bin\Python1.5.2\Lib\threading.py", line 351, in
start</tt>
<br><tt>    assert self.__initialized, "Thread.__init__()
not called"</tt>
<br><tt>AssertionError: Thread.__init__() not called</tt><tt></tt>
<p><tt>Here is a small test case the causes the problem:</tt><tt></tt>
<p><tt>import time</tt>
<br><tt>import threading</tt><tt></tt>
<p><tt>def DoWork(numLoops, name, otherInfo):</tt>
<br><tt> i = 0;</tt>
<br><tt> while ( i < numLoops):</tt>
<br><tt>  print "hello from thread ", name, ", number ", i, ", other
info is ", otherInfo</tt>
<br><tt>  time.sleep(1)</tt>
<br><tt>  i = i + 1</tt>
<br><tt> </tt><tt></tt>
<p><tt>class SimpleThread(threading.Thread):</tt>
<br><tt> def __init__(self,inOtherInfo):</tt>
<br><tt>  self.theOtherInfo = inOtherInfo</tt>
<br><tt>  print "setting other info to '" + self.theOtherInfo + "'"</tt>
<br><tt> def run(self):</tt>
<br><tt>  try:</tt>
<br><tt>   DoWork(20, self.getName(), self.theOtherInfo)</tt>
<br><tt>  finally:</tt>
<br><tt>   pass</tt><tt></tt>
<p><tt>def TestThreads(numThreads):</tt>
<br><tt> try:</tt>
<br><tt>  o = "other info"</tt>
<br><tt>  threads = []</tt>
<br><tt>  for i in range(numThreads):</tt>
<br><tt>   thread = SimpleThread(o)</tt>
<br><tt>   threads.append(thread)</tt>
<br><tt>  for thread in threads:</tt>
<br><tt>   thread.start()</tt>
<br><tt>  for thread in threads:</tt>
<br><tt>   thread.join()</tt>
<br><tt>  print "done testing loggin threads."</tt>
<br><tt> finally:</tt>
<br><tt>  del o</tt><tt></tt>
<p><tt>TestThreads(2)</tt>
<br><tt></tt> 
<br><tt></tt> 
<br><tt></tt> </html>