Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Queue import Queue
- import threading
- def scrape(queue):
- global workers
- print worker.getName()
- print queue.get()
- queue.task_done()
- workers -= 1
- queue = Queue(maxsize=0)
- threads = 10
- workers = 0
- with open('test.txt') as in_file:
- for line in in_file:
- queue.put(line)
- while not (queue.empty()):
- if (threads != workers):
- worker = threading.Thread(target=scrape, args=(queue,))
- worker.setDaemon(True)
- worker.start()
- workers += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement