我是 python 和并行 Python 的新手。问题是我有 4 项工作要做:生成 4 个蒙版,将它们与我的输入图像相乘,然后进行进一步处理。以下是为并行处理编写的一段代码。
inputs = range(4)
jobs = [(inpt, job_server.submit(PP, (inpt,input_data,size,(imageMultiply,blockCounter,imageQuantizer ), ("numpy","Image"))) for inpt in inputs]
job_server.print_stats()
for inpt, job in jobs:
print "No of blocks in ", inpt, "is", job() ## accessing the result of pp
我得到的输出是:
Starting pp with 4 workers
Job execution statistics:
job count | % of all jobs | job time sum | time per job | job server
4 | 100.00 | 0.0000 | 0.000000 | local
Time elapsed since server creation 0.0219678878784
4 active tasks, 4 cores
No of blocks in 0 is 52
No of blocks in 1 is 61
No of blocks in 2 is 104
No of blocks in 3 is 48
我无法理解,如果它不同时处理,我仍然能够获得所需的输出,但是花费的时间太大,这就是我想使用 pp 的原因。请帮助我,以便我可以成功减少时间。提前致谢...