本文整理汇总了Python中paleomix.atomiccmd.command.AtomicCmd.terminate方法的典型用法代码示例。如果您正苦于以下问题:Python AtomicCmd.terminate方法的具体用法?Python AtomicCmd.terminate怎么用?Python AtomicCmd.terminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paleomix.atomiccmd.command.AtomicCmd
的用法示例。
在下文中一共展示了AtomicCmd.terminate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_atomiccmd__terminate_race_condition
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_atomiccmd__terminate_race_condition(temp_folder):
cmd = AtomicCmd("true")
cmd.run(temp_folder)
while cmd._proc.poll() is None:
pass
cmd.terminate()
assert_equal(cmd.join(), [0])
示例2: test_pformat__simple__running__set_cwd
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_pformat__simple__running__set_cwd(temp_folder):
cmd = AtomicCmd(("sleep", "10"), set_cwd=True)
cmd.run(temp_folder)
assert_equal(pformat(cmd), ("<Command = ['sleep', '10']\n"
" Status = Running ...\n"
" STDOUT* = 'pipe_sleep_{id}.stdout'\n"
" STDERR* = 'pipe_sleep_{id}.stderr'\n"
" CWD = '{temp_dir}'>").format(id=id(cmd),
temp_dir=temp_folder))
cmd.terminate()
cmd.join()
示例3: test_pformat__simple__killed
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_pformat__simple__killed(temp_folder):
cmd = AtomicCmd(("sleep", "10"))
cmd.run(temp_folder)
cmd.terminate()
assert_equal(cmd.join(), ["SIGTERM"])
assert_equal(pformat(cmd), ("<Command = ['sleep', '10']\n"
" Status = Terminated with signal SIGTERM\n"
" STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
" STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
" CWD = '{cwd}'>").format(id=id(cmd),
temp_dir=temp_folder,
cwd=os.getcwd()))
示例4: test_pformat__simple__running
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_pformat__simple__running(temp_folder):
cmd = AtomicCmd(("sleep", "10"))
cmd.run(temp_folder)
assert_equal(pformat(cmd),
("Command = sleep 10\n"
"Status = Running ...\n"
"STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
"STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
"CWD = '{cwd}'").format(id=id(cmd),
cwd=os.getcwd(),
temp_dir=temp_folder))
cmd.terminate()
cmd.join()
示例5: test_pformat__simple__terminated_by_pipeline
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_pformat__simple__terminated_by_pipeline(temp_folder):
cmd = AtomicCmd(("sleep", "10"))
cmd.run(temp_folder)
cmd.terminate()
assert_equal(cmd.join(), ["SIGTERM"])
assert_equal(pformat(cmd),
("Command = sleep 10\n"
"Status = Automatically terminated by PALEOMIX\n"
"STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
"STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
"CWD = '{cwd}'").format(id=id(cmd),
temp_dir=temp_folder,
cwd=os.getcwd()))
示例6: _do_test_atomiccmd__terminate
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def _do_test_atomiccmd__terminate(temp_folder, raise_on_terminate):
cmd = AtomicCmd(("sleep", "10"))
cmd.run(temp_folder)
killpg_was_called = []
def _wrap_killpg(pid, sig):
assert_equal(pid, cmd._proc.pid)
assert_equal(sig, signal.SIGTERM)
killpg_was_called.append(True)
if raise_on_terminate:
raise OSError("KABOOM!")
with Monkeypatch("os.killpg", _wrap_killpg):
cmd.terminate()
cmd.terminate()
assert_equal(cmd.join(), ["SIGTERM"])
assert killpg_was_called
示例7: test_atomiccmd__commit_while_running
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_atomiccmd__commit_while_running(temp_folder):
cmd = AtomicCmd(("sleep", "10"))
cmd.run(temp_folder)
assert_raises(CmdError, cmd.commit, temp_folder)
cmd.terminate()
cmd.join()
示例8: test_atomiccmd__terminate_sigterm
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_atomiccmd__terminate_sigterm(temp_folder):
cmd = AtomicCmd(("sleep", "10"))
cmd.run(temp_folder)
cmd.terminate()
assert_equal(cmd.join(), ["SIGTERM"])
示例9: test_atomiccmd__terminate_after_join
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_atomiccmd__terminate_after_join(temp_folder):
cmd = AtomicCmd("true")
cmd.run(temp_folder)
assert_equal(cmd.join(), [0])
cmd.terminate()
assert_equal(cmd.join(), [0])
示例10: test_atomiccmd__run__invalid_temp
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_atomiccmd__run__invalid_temp(temp_files):
cmd = AtomicCmd(("sleep", "10"))
assert_raises(CmdError, cmd.run, os.path.join(temp_files, "foo"))
cmd.terminate()
cmd.join()
示例11: test_atomiccmd__run__exception_on_missing_command__no_wrap
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_atomiccmd__run__exception_on_missing_command__no_wrap(temp_files):
cmd = AtomicCmd(("xyzabcefgh", "10"))
assert_raises(OSError, cmd.run, temp_files, wrap_errors=False)
cmd.terminate()
cmd.join()
示例12: test_atomiccmd__run__exception_on_missing_command
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_atomiccmd__run__exception_on_missing_command(temp_files):
cmd = AtomicCmd(("xyzabcefgh", "10"))
assert_raises(CmdError, cmd.run, temp_files)
cmd.terminate()
cmd.join()
示例13: test_atomiccmd__run__already_running
# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import terminate [as 别名]
def test_atomiccmd__run__already_running(temp_files):
cmd = AtomicCmd(("sleep", "10"))
cmd.run(temp_files)
assert_raises(CmdError, cmd.run, temp_files)
cmd.terminate()
cmd.join()