Python利用subprocess起進程
阿新 • • 發佈:2018-01-14
apply async sin style star main pro blog targe
from multiprocessing import Process, Pool import time import subprocess def task(msg): print ‘hello, %s‘ % msg time.sleep(1) def test_pool(): pool = Pool(processes=4) for x in range(10): pool.apply_async(task, args=(x,)) print "for end" pool.close() print "pool close" pool.join() print "pool join" print ‘processes done.‘ def test_process(): p = Process(target=task, args=(command,)) p.start() p.join() if __name__ == ‘__main__‘: test_pool()
Python利用subprocess起進程