from multiprocessing import Process
import os
import time
def func(name):
print('Run child process %s (%s)...' % (name, os.getpid()))
time.sleep(3)
if __name__=='__main__':
print('Parent process %s.' % os.getpid())
process_list = []
for i in range(8):
p = Process(target=func, args=('process_%d'%(i),))
process_list.append(p)
print('Child process will start.')
for p in process_list:
p.start()
finished = False
while not (sum([p.is_alive() for p in process_list]) == 0):
time.sleep(0.1)
print('main process')
continue
#for p in process_list:
# p.join()
print('Child process end.')