Pool with files

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from multiprocessing import Pool
def resulter(target):
target.write('test\n')
if __name__ == '__main__':
p = Pool(5)
jobs = []
f = []
for i in xrange(5):
f.append(open('file'+str(i),'w'))
jobs.append( p.apply_async(resulter,[f[i]]) )
for job in jobs:
job.wait()
print job.successful()
def reference():
f = []
for i in xrange(5):
f.append(open('tfile'+str(i),'w'))
resulter(f[i])