[root@centos6 multiprocess]# cat multi_proc_pool.py
#!/usr/bin/env python
#encoding:utf8
import multiprocessing
import os,sys,time
result = []
def run(x,msg):
print 'who-->I Love You __Forever 第%s次' %x,os.getpid(),msg
time.sleep(2)
'''no more than --> timeout=5 or it will raise exception:"TimeoutError"
and do not execute next line...'''
#print "Love ulimited..."
p = multiprocessing.Pool(processes=25)
for i in range(100):
result.append(p.apply_async(run,('%s' %i,'iber')))
#p.apply_async(run,("iber",))
#p.apply_async(run,("yinting",)).get()
p.close()
for res in result:
res.get(timeout=5)