Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
1c8e9f93
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1c8e9f93
编写于
3月 14, 2018
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'clebergnu/fddrainer_flush_fileno_v2'
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
6805d780
0072617c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
2 deletion
+43
-2
avocado/utils/process.py
avocado/utils/process.py
+7
-2
selftests/unit/test_utils_process.py
selftests/unit/test_utils_process.py
+36
-0
未找到文件。
avocado/utils/process.py
浏览文件 @
1c8e9f93
...
@@ -31,7 +31,7 @@ import sys
...
@@ -31,7 +31,7 @@ import sys
import
threading
import
threading
import
time
import
time
from
io
import
BytesIO
from
io
import
BytesIO
,
UnsupportedOperation
from
six
import
string_types
from
six
import
string_types
from
.
import
gdb
from
.
import
gdb
...
@@ -419,7 +419,12 @@ class FDDrainer(object):
...
@@ -419,7 +419,12 @@ class FDDrainer(object):
# the same interface, so let's try to use it if available
# the same interface, so let's try to use it if available
stream
=
getattr
(
handler
,
'stream'
,
None
)
stream
=
getattr
(
handler
,
'stream'
,
None
)
if
(
stream
is
not
None
)
and
(
not
stream
.
closed
):
if
(
stream
is
not
None
)
and
(
not
stream
.
closed
):
os
.
fsync
(
stream
.
fileno
())
if
hasattr
(
stream
,
'fileno'
):
try
:
fileno
=
stream
.
fileno
()
os
.
fsync
(
fileno
)
except
UnsupportedOperation
:
pass
if
hasattr
(
handler
,
'close'
):
if
hasattr
(
handler
,
'close'
):
handler
.
close
()
handler
.
close
()
...
...
selftests/unit/test_utils_process.py
浏览文件 @
1c8e9f93
import
io
import
logging
import
logging
import
os
import
os
import
unittest
import
unittest
...
@@ -305,6 +306,41 @@ class FDDrainerTests(unittest.TestCase):
...
@@ -305,6 +306,41 @@ class FDDrainerTests(unittest.TestCase):
b
"should go to the log
\n
"
)
b
"should go to the log
\n
"
)
self
.
assertTrue
(
handler
.
caught_record
)
self
.
assertTrue
(
handler
.
caught_record
)
def
test_flush_on_closed_handler
(
self
):
handler
=
logging
.
StreamHandler
(
io
.
StringIO
())
log
=
logging
.
getLogger
(
"test_flush_on_closed_handler"
)
log
.
addHandler
(
handler
)
read_fd
,
write_fd
=
os
.
pipe
()
result
=
process
.
CmdResult
()
fd_drainer
=
process
.
FDDrainer
(
read_fd
,
result
,
name
=
"test"
,
stream_logger
=
log
)
fd_drainer
.
start
()
os
.
close
(
write_fd
)
self
.
assertIsNotNone
(
fd_drainer
.
_stream_logger
)
one_stream_closed
=
False
for
handler
in
fd_drainer
.
_stream_logger
.
handlers
:
stream
=
getattr
(
handler
,
'stream'
,
None
)
if
stream
is
not
None
:
if
hasattr
(
stream
,
'close'
):
# force closing the handler's stream to check if
# flush will adapt to it
stream
.
close
()
one_stream_closed
=
True
self
.
assertTrue
(
one_stream_closed
)
fd_drainer
.
flush
()
def
test_flush_on_handler_with_no_fileno
(
self
):
handler
=
logging
.
StreamHandler
(
io
.
StringIO
())
log
=
logging
.
getLogger
(
"test_flush_on_handler_with_no_fileno"
)
log
.
addHandler
(
handler
)
read_fd
,
write_fd
=
os
.
pipe
()
result
=
process
.
CmdResult
()
fd_drainer
=
process
.
FDDrainer
(
read_fd
,
result
,
name
=
"test"
,
stream_logger
=
log
)
fd_drainer
.
start
()
os
.
close
(
write_fd
)
fd_drainer
.
flush
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录