联想E40 中的ubuntu12.04与 12.10

抛弃了ubuntu12.10 是由于 E40 0578mdc的显卡驱动不可用,本身笔记本2个小时的耗电,结果变成了20分钟,并且笔记本温度可以当暖宝宝

重新换回12.04后,发现我所使用的python存在bug
bug测试代码

#!/usr/bin/python

import os
import thread
import threading
import time

def t():
threading.currentThread() # Populate threading._active with a DummyThread
time.sleep(3)

thread.start_new_thread(t, ())

time.sleep(1)

pid = os.fork()
if pid == 0:
os._exit(0)

os.waitpid(pid, 0)
输出结果
songtao@ThinkPad:~$ python bad.py
Exception AttributeError: AttributeError("'_DummyThread' object has no attribute '_Thread__block'",) in <module 'threading' from '/usr/lib/python2.7/threading.py'> ignored

解决办法:
修改 /usr/lib/python2.7/threading.py 文件
参照官方
http://hg.python.org/cpython/rev/ab9d6c4907e7

--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -605,6 +605,10 @@ class Thread(_Verbose):
pass

def __stop(self):
+ # DummyThreads delete self.__block, but they have no waiters to
+ # notify anyway (join() is forbidden on them).
+ if not hasattr(self, '_Thread__block'):
+ return
self.__block.acquire()
self.__stopped = True
self.__block.notify_all()

 

posted on 2013-01-15 15:20  s-tao  阅读(178)  评论(0编辑  收藏  举报

导航