【文件属性】:
文件名称:对Python中创建进程的两种方式以及进程池详解
文件大小:45KB
文件格式:PDF
更新时间:2021-01-20 04:47:31
程池 进程
在Python中创建进程有两种方式,第一种是:
from multiprocessing import Process
import time
def test():
while True:
print('---test---')
time.sleep(1)
if __name__ == '__main__':
p=Process(target=test)
p.start()
while True:
print('---main---')
time.sleep(1)
上面这段代码是在windows下跑的,通过Process类可以创建一个进程对象,然后p.start()