我是python新手。我正在尝试手册中的这个代码片段,但我收到了这个错误。无法弄清楚为什么。任何帮助将不胜感激。谢谢
阿比
代码片段
#/usr/bin/python
# -*- coding: utf-8 -*-
from multiprocessing import Pool
def f(x):
return x*x
p = Pool(1)
p.map(f, [1, 2, 3])
错误
[root@localhost mpls-perf]# python thr_1.py
Traceback (most recent call last):
File "thr_1.py", line 4, in <module>
from multiprocessing import Pool
File "/usr/lib64/python2.7/multiprocessing/__init__.py", line 65, in <module>
from multiprocessing.util import SUBDEBUG, SUBWARNING
File "/usr/lib64/python2.7/multiprocessing/util.py", line 340, in <module>
class ForkAwareLocal(threading.local):
AttributeError: 'module' object has no attribute 'local'
Exception AttributeError: '_shutdown' in <module 'threading'
from '/root/nfs/zebos/tests/mpls- perf/threading.pyc'> ignored
操作系统等 [root@localhost mpls-perf]# uname -a Linux localhost.localdomain 3.4.4464bit-smp-xp1.1-allpatch #1 SMP Wed Oct 15 17:34:02 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost mpls-perf]# python -V Python 2.7.5 [root@localhost mpls-perf]