我使用的是启用berkdb来存储一个巨大的键值对的列表中,但由于某种原因,当我尝试访问某些数据后,我得到这个错误:

try:
    key = 'scrape011201-590652'
    contenttext = contentdict[key]
except:
    print the error


<type 'exceptions.KeyError'> 'scrape011201-590652' in 
contenttext = contentdict[key]\n', '  File "/usr/lib64/python2.5/bsddb/__init__.py",
line 223, in __getitem__\n    return _DeadlockWrap(lambda: self.db[key])  #   
self.db[key]\n', 'File "/usr/lib64/python2.5/bsddb/dbutils.py", line 62, in 
DeadlockWrap\n    return function(*_args, **_kwargs)\n', '  File 
"/usr/lib64/python2.5/bsddb/__init__.py", line 223, in <lambda>\n    return 
_DeadlockWrap(lambda: self.db[key])  # self.db[key]\n']

我不知道什么是DeadlockWrap但心不是任何其他程序或进程访问启用berkdb或写它(据我所知)所以不知道我们如何能够得到一个僵局,如果它指的是。难道我试图访问数据迅速?我在一个循环中调用该函数,所以像

for i in hugelist:
    #try to get a value from the berkdb
    #do something with it

我有多个数据集运行这个和这个错误只与其中一人发生最大的一个,而不是其他。

其他提示

contenttext = contentdict[key] if contentdict.has_key(key) else None
scroll top