I have a scenario like this :
for each in content :
pdf_output,job_id=createpdf(each)
if pdf_output :
pdf_output = pdf_output + pdf_output
You do not need queues for such a simple task. I would recommend to use pools. The Pool.map
method can apply a function to a series of values in parallel:
import multiprocessing
def createpdf(data):
return ("This is my pdf data: %s\n" % data, 0)
data = [ "My data", "includes", "strings and", "numbers like", 42, "and", 3.14]
number_of_processes = 5
results = multiprocessing.Pool(number_of_processes).map(createpdf, data)
outputs = [result[0] for result in results]
pdfoutput = "".join(outputs)