提交 0a148e06 authored 作者: Frederic's avatar Frederic

Work around reading the cache without the lock

上级 c56444ff
...@@ -1111,8 +1111,18 @@ class ModuleCache(object): ...@@ -1111,8 +1111,18 @@ class ModuleCache(object):
# Verify that when we reload the KeyData from the pickled file, the # Verify that when we reload the KeyData from the pickled file, the
# same key can be found in it, and is not equal to more than one # same key can be found in it, and is not equal to more than one
# other key. # other key.
with open(key_pkl, 'rb') as f: for i in range(3):
key_data = cPickle.load(f) try:
with open(key_pkl, 'rb') as f:
key_data = cPickle.load(f)
break
except EOFError:
# This file is probably getting written/updated at the
# same time. This can happen as we read the cache
# without taking the lock.
if i == 2:
raise
time.sleep(2)
found = sum(key == other_key for other_key in key_data.keys) found = sum(key == other_key for other_key in key_data.keys)
msg = '' msg = ''
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论