import threadpool import threading mutex = threading.Lock() def write_to_file(file_name,text): mutex.acquire() a = open(file_name,'a') a.write(text+" ") a.close() mutex.release()
a = open("a") password_list = [] for i in a.readlines(): i = i.strip(" ") i = i.strip(" ") i = i.split(" ") if len(i) < 2: pass else: password_list.append((i,None)) pool = threadpool.ThreadPool(30) requests_a = threadpool.makeRequests(req, password_list) [pool.putRequest(req) for req in requests_a] pool.wait()