本文整理汇总了Python中subprocess.Popen.timed_out方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.timed_out方法的具体用法?Python Popen.timed_out怎么用?Python Popen.timed_out使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.Popen
的用法示例。
在下文中一共展示了Popen.timed_out方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_test
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import timed_out [as 别名]
def run_test(self, cfg_name):
# Prepare test environment and generate command for it
test = self.read_test_config(cfg_name)
test_bin = os.path.basename(test.bins[0])
if test.is_dist:
# Distribution-wide tests should work with default environment
test_env = os.environ
else:
test_env = self.generate_env()
self.prepare_test_dir(test)
command = test_bin
if not test.is_dist:
command = os.path.join(self.bin_dir, test_bin)
if test.args is not None:
command = '%s %s' % (command, test.args)
# Start a test along with a timer that would check
# If test wouldn't timeout
start = time.time()
proc = Popen(command,
stdout = PIPE,
stderr = PIPE,
cwd = self.test_dir,
env = test_env,
shell = test.is_dist or test.args)
proc.timed_out = False
timer = Timer(test.maxtime, self.stop_test, args = [proc])
timer.start()
(stdout, stderr) = proc.communicate()
timer.cancel()
end = time.time()
# Check test result: core, return value
core = self.check_core(cfg_name, test.group)
result = self.analyze_result(test, proc)
# Generate test report
output = self.generate_output(command, start, end, proc,
core, stdout, stderr)
# Done
self.suite.report_test('%s/%s' % (test.group, test.name),
result, proc.returncode,
output)