我正在尝试创建几个进程并通过 Python 多处理模块运行它们,我使用下面的代码来确定正在提交的每个进程的进程名称,但我注意到所有进程都在同一个处理器上运行,至少名称看起来相同.
作业何时开始在其他处理器上运行?如何识别其运行的处理器名称?
from multiprocessing import Process
import platform
def process1():
print 'process_1 processor =',platform.processor()
def process2():
print 'process_2 processor =',platform.processor()
def main():
print 'Main processor =',platform.processor()
processlist = []
p1 = Process(target = process1)
p1.start()
processlist.append(p1)
p2 = Process(target = process2)
p2.start()
processlist.append(p2)
for i in processlist:
i.join()
if __name__ == '__main__':
main()
OUtput
Main processor = Intel64 Family 6 Model 37 Stepping 2, GenuineIntel
process_2 processor = Intel64 Family 6 Model 37 Stepping 2, GenuineIntel
process_1 processor = Intel64 Family 6 Model 37 Stepping 2, GenuineIntel