Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2bb303f4
提交
2bb303f4
authored
5月 27, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor improvements to cache system
上级
0d56d163
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
14 行删除
+27
-14
cmodule.py
theano/gof/cmodule.py
+27
-14
没有找到文件。
theano/gof/cmodule.py
浏览文件 @
2bb303f4
...
@@ -274,9 +274,20 @@ class KeyData(object):
...
@@ -274,9 +274,20 @@ class KeyData(object):
self
.
save_pkl
()
self
.
save_pkl
()
def
save_pkl
(
self
):
def
save_pkl
(
self
):
"""Dump this object into its `key_pkl` file."""
"""
cPickle
.
dump
(
self
,
open
(
self
.
key_pkl
,
'wb'
),
Dump this object into its `key_pkl` file.
protocol
=
cPickle
.
HIGHEST_PROTOCOL
)
May raise a cPickle.PicklingError if such an exception is raised at
pickle time (in which case a warning is also displayed).
"""
# Note that writing in binary mode is important under Windows.
try
:
cPickle
.
dump
(
self
,
open
(
self
.
key_pkl
,
'wb'
),
protocol
=
cPickle
.
HIGHEST_PROTOCOL
)
except
cPickle
.
PicklingError
:
warning
(
"Cache leak due to unpickle-able key data"
,
key_data
.
keys
)
os
.
remove
(
self
.
key_pkl
)
raise
class
ModuleCache
(
object
):
class
ModuleCache
(
object
):
...
@@ -389,7 +400,7 @@ class ModuleCache(object):
...
@@ -389,7 +400,7 @@ class ModuleCache(object):
key_pkl
=
os
.
path
.
join
(
root
,
'key.pkl'
)
key_pkl
=
os
.
path
.
join
(
root
,
'key.pkl'
)
if
key_pkl
in
self
.
loaded_key_pkl
:
if
key_pkl
in
self
.
loaded_key_pkl
:
continue
continue
elif
'delete.me'
in
files
or
len
(
files
)
==
0
:
elif
'delete.me'
in
files
or
not
files
:
# On NFS filesystems, it is impossible to delete a directory with open
# On NFS filesystems, it is impossible to delete a directory with open
# files in it. So instead, some commands in this file will respond to a
# files in it. So instead, some commands in this file will respond to a
# failed rmtree() by touching a 'delete.me' file. This file is a message
# failed rmtree() by touching a 'delete.me' file. This file is a message
...
@@ -397,8 +408,17 @@ class ModuleCache(object):
...
@@ -397,8 +408,17 @@ class ModuleCache(object):
try
:
try
:
shutil
.
rmtree
(
root
)
shutil
.
rmtree
(
root
)
except
:
except
:
# the directory is still in use?? We just leave it for future removal.
# Maybe directory is still in use? We just leave it
pass
# for future removal (and make sure there is a
# delete.me file in it).
delete_me
=
os
.
path
.
join
(
root
,
'delete.me'
)
if
not
os
.
path
.
exists
(
delete_me
):
try
:
open
(
delete_me
,
'w'
)
except
:
# Giving up!
warning
(
"Cannot mark cache directory for "
"deletion:
%
s"
%
root
)
elif
'key.pkl'
in
files
:
elif
'key.pkl'
in
files
:
try
:
try
:
entry
=
module_name_from_dir
(
root
)
entry
=
module_name_from_dir
(
root
)
...
@@ -622,17 +642,10 @@ class ModuleCache(object):
...
@@ -622,17 +642,10 @@ class ModuleCache(object):
keys
=
set
([
key
]),
keys
=
set
([
key
]),
module_hash
=
get_module_hash
(
name
,
key
),
module_hash
=
get_module_hash
(
name
,
key
),
key_pkl
=
key_pkl
)
key_pkl
=
key_pkl
)
# Note that using a binary file is important under Windows.
key_file
=
open
(
key_pkl
,
'wb'
)
try
:
try
:
cPickle
.
dump
(
key_data
,
key_file
,
key_data
.
save_pkl
()
cPickle
.
HIGHEST_PROTOCOL
)
key_file
.
close
()
key_broken
=
False
key_broken
=
False
except
cPickle
.
PicklingError
:
except
cPickle
.
PicklingError
:
key_file
.
close
()
os
.
remove
(
key_pkl
)
warning
(
"Cache leak due to unpickle-able key"
,
key
)
key_broken
=
True
key_broken
=
True
if
not
key_broken
:
if
not
key_broken
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论