This code runs ok for a little bit, then it gives me this error:
thread.error: can't start new thread
What am I doing wrong? The names file is about 10,000 names long, the email file is about 5 emails long.
for x in open(names):
name = x.strip()
def check(q):
while True:
email = q.get()
lock.acquire()
print email, name, threading.active_count()
lock.release()
#Do things in
#the internet
q.task_done()
return
for i in range(threads):
t = threading.Thread(target=check, args=(q,))
t.setDaemon(True)
t.start()
for word in open(emails):
q.put(word.strip())
q.join()
I only specify 2 threads, but it ends up creating hundreds then crashes when the active_count is around 890. How can I fix this?
for x in open(names):. This is what you actually wanted?checkfunction never returns.so, those threads are still alive.