这段代码可以在Mac上正常运行(windows不行)
# build.py
from multiprocessing import Pool
import traceback
def f(x):
print 'start pool.f'
return x*x
def run():
for line in traceback.format_stack():
print(line.strip())
print 'start pool.run'
pool = Pool(processes=1)
print 'start pool.map'
print pool.map(f, range(10))
run()
最终输出
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
但是,如果通过下面的代码运行,程序就会死掉
# jenkins.py
import build
print "doesn't run this line at all. the program is hanging in import"
build.run()
build.f()
build.inexist_fuction("the function doesn't exist, python doesn't have chance to check it")