Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
865099c2
提交
865099c2
authored
3月 14, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
3月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Let filelock determine valid values for timeout
上级
66d973bd
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
4 行增加
和
15 行删除
+4
-15
compilelock.py
aesara/compile/compilelock.py
+4
-5
test_compilelock.py
tests/compile/test_compilelock.py
+0
-10
没有找到文件。
aesara/compile/compilelock.py
浏览文件 @
865099c2
...
...
@@ -4,8 +4,8 @@ in the same compilation directory (which can cause crashes).
"""
import
os
import
threading
import
typing
from
contextlib
import
contextmanager
from
typing
import
Optional
import
filelock
...
...
@@ -45,7 +45,7 @@ def force_unlock(lock_dir: os.PathLike):
@contextmanager
def
lock_ctx
(
lock_dir
:
os
.
PathLike
=
None
,
*
,
timeout
:
typing
.
Optional
[
float
]
=
-
1
):
def
lock_ctx
(
lock_dir
:
os
.
PathLike
=
None
,
*
,
timeout
:
Optional
[
float
]
=
None
):
"""Context manager that wraps around FileLock and SoftFileLock from filelock package.
Parameters
...
...
@@ -59,10 +59,9 @@ def lock_ctx(lock_dir: os.PathLike = None, *, timeout: typing.Optional[float] =
"""
if
lock_dir
is
None
:
lock_dir
=
config
.
compiledir
if
timeout
==
-
1
:
if
timeout
is
None
:
timeout
=
config
.
compile__timeout
elif
not
(
timeout
is
None
or
timeout
>
0
):
raise
ValueError
(
f
"Timeout parameter must be None or positive. Got {timeout}."
)
# locks are kept in a dictionary to account for changing compiledirs
dir_key
=
f
"{lock_dir}-{os.getpid()}"
...
...
tests/compile/test_compilelock.py
浏览文件 @
865099c2
...
...
@@ -11,16 +11,6 @@ import pytest
from
aesara.compile.compilelock
import
force_unlock
,
local_mem
,
lock_ctx
def
test_compilelock_errors
():
with
tempfile
.
TemporaryDirectory
()
as
dir
:
with
pytest
.
raises
(
ValueError
):
with
lock_ctx
(
dir
,
timeout
=
0
):
pass
with
pytest
.
raises
(
ValueError
):
with
lock_ctx
(
dir
,
timeout
=-
2
):
pass
def
test_compilelock_force_unlock
():
with
tempfile
.
TemporaryDirectory
()
as
dir_name
:
with
lock_ctx
(
dir_name
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论