Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4c320661
提交
4c320661
authored
5月 24, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some fixes to new cache mechanism
上级
77223d49
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
29 行增加
和
6 行删除
+29
-6
cmodule.py
theano/gof/cmodule.py
+29
-6
没有找到文件。
theano/gof/cmodule.py
浏览文件 @
4c320661
...
@@ -408,18 +408,32 @@ class ModuleCache(object):
...
@@ -408,18 +408,32 @@ class ModuleCache(object):
continue
continue
if
(
time_now
-
last_access_time
(
entry
))
<
self
.
age_thresh_use
:
if
(
time_now
-
last_access_time
(
entry
))
<
self
.
age_thresh_use
:
debug
(
'refresh adding'
,
key_pkl
)
debug
(
'refresh adding'
,
key_pkl
)
def
unpickle_failure
():
info
(
"ModuleCache.refresh() Failed to unpickle "
"cache file"
,
key_pkl
)
try
:
try
:
key_data
=
cPickle
.
load
(
open
(
key_pkl
,
'rb'
))
key_data
=
cPickle
.
load
(
open
(
key_pkl
,
'rb'
))
except
EOFError
:
# Happened once... not sure why (would be worth
# investigating).
unpickle_failure
()
warning
(
"Erasing broken cache directory [EOF]"
,
root
)
shutil
.
rmtree
(
root
)
continue
except
:
except
:
info
(
"ModuleCache.refresh() Failed to unpickle "
# For now, raise exceptions, in order to be able to
"cache file"
,
key_pkl
)
# figure out which exceptions should be caught.
# TODO Make it more user-friendly by not raising
# the exception.
raise
unpickle_failure
()
if
False
:
if
False
:
info
(
"Erasing broken cache directory"
,
key_pkl
)
info
(
"Erasing broken cache directory"
,
root
)
shutil
.
rmtree
(
root
)
shutil
.
rmtree
(
root
)
else
:
else
:
# This exception is often triggered by keys that contain
# This exception is often triggered by keys that contain
# references to classes that have not yet been imported. They are
# references to classes that have not yet been imported. They are
# not necessarily broken
# not necessarily broken
.
pass
pass
continue
continue
...
@@ -665,16 +679,25 @@ class ModuleCache(object):
...
@@ -665,16 +679,25 @@ class ModuleCache(object):
too_old_to_use
=
[(
None
,
entry
)
for
entry
in
too_old_to_use
]
too_old_to_use
=
[(
None
,
entry
)
for
entry
in
too_old_to_use
]
time_now
=
time
.
time
()
time_now
=
time
.
time
()
# the .items() is important here:
# the .ite
rite
ms() is important here:
# we need to get a copy of the whole list of keys and entries
# we need to get a copy of the whole list of keys and entries
items_copy
=
list
(
self
.
entry_from_key
.
iteritems
())
items_copy
=
list
(
self
.
entry_from_key
.
iteritems
())
for
key
,
entry
in
items_copy
+
too_old_to_use
:
all_items
=
items_copy
+
too_old_to_use
# Since multiple keys may share the same entry, we turn this list
# of pairs into a dictionary that maps an entry to the list of keys
# that use it.
entry_to_keys
=
dict
((
entry
,
[])
for
key
,
entry
in
all_items
)
for
key
,
entry
in
all_items
:
entry_to_keys
[
entry
]
.
append
(
key
)
for
entry
,
keys
in
entry_to_keys
.
iteritems
():
age
=
time_now
-
last_access_time
(
entry
)
age
=
time_now
-
last_access_time
(
entry
)
if
age
>
age_thresh_del
:
if
age
>
age_thresh_del
:
# TODO: we are assuming that modules that haven't been accessed in over
# TODO: we are assuming that modules that haven't been accessed in over
# age_thresh_del are not currently in use by other processes, but that could be
# age_thresh_del are not currently in use by other processes, but that could be
# false for long-running jobs...
# false for long-running jobs...
assert
entry
not
in
self
.
module_from_name
assert
entry
not
in
self
.
module_from_name
for
key
in
keys
:
if
key
is
not
None
:
if
key
is
not
None
:
del
self
.
entry_from_key
[
key
]
del
self
.
entry_from_key
[
key
]
parent
=
os
.
path
.
dirname
(
entry
)
parent
=
os
.
path
.
dirname
(
entry
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论