當前位置: 首頁>>代碼示例>>Python>>正文


Python AtomicCmd.terminate方法代碼示例

本文整理匯總了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])
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:9,代碼來源:command_test.py

示例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()
開發者ID:muslih14,項目名稱:paleomix,代碼行數:13,代碼來源:pprint_test.py

示例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()))
開發者ID:muslih14,項目名稱:paleomix,代碼行數:14,代碼來源:pprint_test.py

示例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()
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:15,代碼來源:pprint_test.py

示例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()))
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:15,代碼來源:pprint_test.py

示例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
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:20,代碼來源:command_test.py

示例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()
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:8,代碼來源:command_test.py

示例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"])
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:7,代碼來源:command_test.py

示例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])
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:8,代碼來源:command_test.py

示例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()
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:7,代碼來源:command_test.py

示例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()
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:7,代碼來源:command_test.py

示例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()
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:7,代碼來源:command_test.py

示例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()
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:8,代碼來源:command_test.py


注:本文中的paleomix.atomiccmd.command.AtomicCmd.terminate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。