Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import time, sleep
- from threading import Thread
- import Queue
- lines = "pichlist.txt"
- number_of_thread = input("Enter the number of thread that you want to use: ")
- user_name = "Doriane"
- user_password = "12121212"
- def autenti(user, passwd):
- sleep(0.2)
- correct = (user == user_name and passwd == user_password)
- print correct
- return correct
- def thread_job(q):
- while not q.empty():
- value = q.get()
- answer = autenti(user_name, value)
- if answer:
- print "The value", value, "was correcte!"
- def get_dict_from_pycharm(lines):
- with open(lines, "rb") as stream:
- data = stream.read().split("\n")
- return data
- def main():
- passwords = get_dict_from_pycharm(lines)
- password_qeue = Queue.Queue()
- for p in passwords:
- password_qeue.put(p)
- start_time = time()
- my_thread = []
- for i in range (number_of_thread):
- t = Thread(target=thread_job, args=(password_qeue,))
- my_thread.append(t)
- t.start()
- for t in my_thread:
- t.join()
- total_time = time() - start_time
- print "This program took",total_time
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement