import subprocess
import multiprocessing
import urllib
import sys
import os
import pymongo
import signal
import time
client=pymongo.MongoClient(
"192.168.139.143",27017
)
db=
client.domaindb
collection=
db.domain
def getdomain(i):
print(
"process id=%d,paren process id=%d,ppange=%d"%
(os.getpid(),os.getppid(),i))
time.sleep(1
)
getdomain(i+1
)if __name__ ==
'__main__':
try:
pool=multiprocessing.Pool(6
)
pool.map(getdomain,range(8
))
#pool.map_async(getdomain,range(9)).get(10)
pool.close()
except KeyboardInterrupt:
print 'get ctrl+c whild pool'
pool.terminate()
#except TimeoutException:
except Exception ,e:
print 'thrwo exception %r'%
(e)
finally:
print 'joining complete'
#pool.join()
print 'join compele'
print 'the end'
转载于:https://www.cnblogs.com/yixiong/p/4904864.html
相关资源:数据结构—成绩单生成器
转载请注明原文地址: https://win8.8miu.com/read-1556469.html