一 进程创建的两种方式 from multiprocessing import Process import time def task(name): print(f'{name} is running') time.sleep(2) print(f'{name} is gone') if __name__ == '__main__': #在windows环境下, 开启进程必须在 __name__ == '__main__' 下面 p = Process(target=task,args=('常…
一,进程的开启方式 利用模块开启进程 from multiprocessing import Process import time,random import os def piao(name): print(os.getppid(),os.getpid()) print('%s is piaoing' %name) # time.sleep(random.randint(1,3)) print('%s is piao end' %name) if __name__ == '__main__'…
一,进程的开启方式 利用模块开启进程 from multiprocessing import Process import time,random import os def piao(name): print(os.getppid(),os.getpid()) print('%s is piaoing' %name) # time.sleep(random.randint(1,3)) print('%s is piao end' %name) if __name__ == '__main__'…