九州体育网 - 十年信誉网站

关于作者

Discuss / Python / 是这样吗

是这样吗

Topic source

萌萌的雀斑狗

#1 Created at ...

import multiprocessing import time

def worker_1(interval): print ("worker_1") time.sleep(3) print ("end worker_1")

def worker_2(interval): print ("worker_2") time.sleep(2) print ("end worker_2")

def worker_3(interval): print ("worker_3") time.sleep(1) print ("end worker_3")

if name == "main": p1 = multiprocessing.Process(target=worker_1, args=(2,)) p2 = multiprocessing.Process(target=worker_2, args=(3,)) p3 = multiprocessing.Process(target=worker_3, args=(4,))

p1.start()
p2.start()
p3.start()

print("The number of CPU is:" + str(multiprocessing.cpu_count()))
for p in multiprocessing.active_children():
    print("child   p.name:" + p.name + "\tp.id" + str(p.pid))
print ("END!!!!!!!!!!!!!!!!!")

  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.