I'm trying to create multiple threads and by using a for loop. I want the threads to then run another part of my script using the iteration number of the loop as a variable. The result of each thread should create a log file which is already defined in my script. For some reason though not all log files are created and not all the tests aren't run:
import thread
import os
def test(x, name):
....
try:
for ip in range(int(start), (int(end) + 1)):
threadname = str(ip)
thread.start_new_thread(test, (ip, threadname, ))
except:
print "Error"
while 1:
pass
I know there is another module called Threading which can be used to make threads but do you think this may be the reason not all my threads are being started? Or is it something else completely?
import sys
andprint sys.exc_info()
inexcept:
block. – ElmoVanKielmo Jul 1 '13 at 15:37try:
) I cannot see obvious errors: all your threads should start. Your code is incomplete so it's hard to understand what your problem is. My suggestion: avoidthread
and usethreading
, it's much more user friendly, and gives you much more control. – Stefano M Jul 1 '13 at 15:51