Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

run thread that inputs into queue and other threads process that python

from queue import Queue
from threading import Thread

queue = Queue(workers * 2)
def work():
    while True:
        myFunction(*queue.get())
        queue.task_done()

for _ in range(workers):
    Thread(target=work, daemon=True).start()

with open(targets, 'r') as listfile:
    for line in listfile:
        queue.put((line, param))
queue.join()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #run #thread #inputs #queue #threads #process #python
ADD COMMENT
Topic
Name
8+7 =