Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
19d905a8
提交
19d905a8
authored
5月 16, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make sure that 'theano-cache' clear actually deletes all modules
上级
01a13aad
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
14 行删除
+17
-14
theano-cache
bin/theano-cache
+1
-1
cmodule.py
theano/gof/cmodule.py
+16
-13
没有找到文件。
bin/theano-cache
浏览文件 @
19d905a8
...
...
@@ -6,7 +6,7 @@ from theano.gof.cc import get_module_cache
if
len
(
sys
.
argv
)
==
1
:
print
config
.
compiledir
elif
sys
.
argv
[
1
]
in
(
'clear'
):
get_module_cache
()
.
clear
()
get_module_cache
()
.
clear
(
unversioned_min_age
=-
1
)
else
:
print
'command "
%
s" not recognized'
%
sys
.
argv
[
1
]
print
'Type "theano-cache" to print the cache location'
...
...
theano/gof/cmodule.py
浏览文件 @
19d905a8
...
...
@@ -471,7 +471,7 @@ class ModuleCache(object):
"key not equal to unpickled version (Hint:"
" verify the __eq__ and __hash__ functions"
" for your Ops"
,
(
key
,
key_from_file
))
# Adding the key file to this set mea
sn
it is a
# Adding the key file to this set mea
ns
it is a
# versioned key.
self
.
loaded_key_pkl
.
add
(
key_pkl
)
except
cPickle
.
UnpicklingError
:
...
...
@@ -491,7 +491,7 @@ class ModuleCache(object):
return
rval
age_thresh_del
=
60
*
60
*
24
*
31
#31 days
age_thresh_del_unversion
n
ed
=
60
*
60
*
24
*
7
#7 days
age_thresh_del_unversioned
=
60
*
60
*
24
*
7
#7 days
"""The default age threshold for `clear_old` (in seconds)
"""
...
...
@@ -510,13 +510,13 @@ class ModuleCache(object):
# update the age of modules that have been accessed by other processes
# and get all module that are too old to use.(not loaded in self.entry_from_key)
too_old_to_use
=
self
.
refresh
()
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
()
# the .items() is important here:
# we need to get a copy of the whole list of keys and entries
items_copy
=
list
(
self
.
entry_from_key
.
iteritems
())
for
key
,
entry
in
items_copy
+
too_old_to_use
:
for
key
,
entry
in
items_copy
+
too_old_to_use
:
age
=
time_now
-
last_access_time
(
entry
)
if
age
>
age_thresh_del
:
# TODO: we are assuming that modules that haven't been accessed in over
...
...
@@ -533,17 +533,19 @@ class ModuleCache(object):
finally
:
compilelock
.
release_lock
()
def
clear
(
self
):
def
clear
(
self
,
unversioned_min_age
=
None
):
"""
Clear all the elements of the cache
"""
self
.
clear_old
(
-
1.0
)
self
.
clear_unversioned
()
self
.
clear_unversioned
(
min_age
=
unversioned_min_age
)
def
clear_unversioned
(
self
):
def
clear_unversioned
(
self
,
min_age
=
None
):
"""Delete unversioned dynamic modules from the internal dictionaries and from the
filesystem.
"""
if
min_age
is
None
:
min_age
=
self
.
age_thresh_del_unversioned
items_copy
=
list
(
self
.
entry_from_key
.
iteritems
())
for
key
,
entry
in
items_copy
:
version
,
rest
=
key
...
...
@@ -571,12 +573,13 @@ class ModuleCache(object):
has_key
=
False
if
not
has_key
:
age
=
time_now
-
last_access_time
(
os
.
path
.
join
(
self
.
dirname
,
filename
))
#In normal case, the processus that created this directory will delete it
#In case this processus crash, it won't be cleaned up.
#As we don't know how to know if this directory is still used
#we wait 1 weak and suppose that the processus crashed
#and we do the clean up for it.
if
age
>
self
.
age_thresh_del_unversionned
:
# In normal case, the processus that created this directory
# will delete it. However, if this processus crashes, it
# will not be cleaned up.
# As we don't know if this directory is still used, we wait
# one week and suppose that the processus crashed, and we
# take care of the clean-up.
if
age
>
min_age
:
info
(
"clear_unversioned removing cache dir"
,
filename
)
_rmtree
(
os
.
path
.
join
(
self
.
dirname
,
filename
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论