代码在同一线程上执行但进程不同

时间:2019-03-04 17:25:34

标签: python-3.x

有人可以解释为什么此代码在同一线程但在不同进程上执行吗?那怎么可能?

from concurrent.futures import ProcessPoolExecutor
import os
import threading


def whereami():
    print("You are on thread {} and on process {}".format(
        threading.get_ident(), os.getpid()))


with ProcessPoolExecutor() as pool:
    whereami()
    pool.submit(whereami)

0 个答案:

没有答案