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


Python subprocess._cleanup方法代碼示例

本文整理匯總了Python中subprocess._cleanup方法的典型用法代碼示例。如果您正苦於以下問題:Python subprocess._cleanup方法的具體用法?Python subprocess._cleanup怎麽用?Python subprocess._cleanup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在subprocess的用法示例。


在下文中一共展示了subprocess._cleanup方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _assert_python

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def _assert_python(expected_success, *args, **env_vars):
    cmd_line = [sys.executable]
    if not env_vars:
        cmd_line.append('-E')
    cmd_line.extend(args)
    # Need to preserve the original environment, for in-place testing of
    # shared library builds.
    env = os.environ.copy()
    env.update(env_vars)
    p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                         env=env)
    try:
        out, err = p.communicate()
    finally:
        subprocess._cleanup()
        p.stdout.close()
        p.stderr.close()
    rc = p.returncode
    err =  strip_python_stderr(err)
    if (rc and expected_success) or (not rc and not expected_success):
        raise AssertionError(
            "Process return code is %d, "
            "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))
    return rc, out, err 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:script_helper.py

示例2: kill_python

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def kill_python(p):
    p.stdin.close()
    data = p.stdout.read()
    p.stdout.close()
    # try to cleanup the child so we don't appear to leak when running
    # with regrtest -R.
    p.wait()
    subprocess._cleanup()
    return data 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:script_helper.py

示例3: tearDown

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def tearDown(self):
        for inst in subprocess._active:
            inst.wait()
        subprocess._cleanup()
        self.assertFalse(subprocess._active, "subprocess._active not empty")
        self.doCleanups()
        test_support.reap_children() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_subprocess.py

示例4: setUp

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def setUp(self):
        popen2._cleanup()
        # When the test runs, there shouldn't be any open pipes
        self.assertFalse(popen2._active, "Active pipes when test starts" +
            repr([c.cmd for c in popen2._active])) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_popen2.py

示例5: tearDown

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def tearDown(self):
        for inst in popen2._active:
            inst.wait()
        popen2._cleanup()
        self.assertFalse(popen2._active, "popen2._active not empty")
        # The os.popen*() API delegates to the subprocess module (on Unix)
        import subprocess
        for inst in subprocess._active:
            inst.wait()
        subprocess._cleanup()
        self.assertFalse(subprocess._active, "subprocess._active not empty")
        reap_children() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:14,代碼來源:test_popen2.py

示例6: tearDown

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def tearDown(self):
        for inst in subprocess._active:
            inst.wait()
        subprocess._cleanup()
        self.assertFalse(subprocess._active, "subprocess._active not empty") 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:7,代碼來源:test_subprocess.py

示例7: run_python_until_end

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def run_python_until_end(*args, **env_vars):
    env_required = interpreter_requires_environment()
    if '__isolated' in env_vars:
        isolated = env_vars.pop('__isolated')
    else:
        isolated = not env_vars and not env_required
    cmd_line = [sys.executable, '-X', 'faulthandler']
    if isolated:
        # isolated mode: ignore Python environment variables, ignore user
        # site-packages, and don't add the current directory to sys.path
        cmd_line.append('-I')
    elif not env_vars and not env_required:
        # ignore Python environment variables
        cmd_line.append('-E')
    # Need to preserve the original environment, for in-place testing of
    # shared library builds.
    env = os.environ.copy()
    # But a special flag that can be set to override -- in this case, the
    # caller is responsible to pass the full environment.
    if env_vars.pop('__cleanenv', None):
        env = {}
    env.update(env_vars)
    cmd_line.extend(args)
    p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                         env=env)
    try:
        out, err = p.communicate()
    finally:
        subprocess._cleanup()
        p.stdout.close()
        p.stderr.close()
    rc = p.returncode
    err = strip_python_stderr(err)
    return _PythonRunResult(rc, out, err), cmd_line 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:37,代碼來源:script_helper.py

示例8: kill_python

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def kill_python(p):
    """Run the given Popen process until completion and return stdout."""
    p.stdin.close()
    data = p.stdout.read()
    p.stdout.close()
    # try to cleanup the child so we don't appear to leak when running
    # with regrtest -R.
    p.wait()
    subprocess._cleanup()
    return data 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:12,代碼來源:script_helper.py

示例9: run_python_until_end

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def run_python_until_end(*args, **env_vars):
    env_required = _interpreter_requires_environment()
    if '__isolated' in env_vars:
        isolated = env_vars.pop('__isolated')
    else:
        isolated = not env_vars and not env_required
    cmd_line = [sys.executable, '-X', 'faulthandler']
    if isolated:
        # isolated mode: ignore Python environment variables, ignore user
        # site-packages, and don't add the current directory to sys.path
        cmd_line.append('-I')
    elif not env_vars and not env_required:
        # ignore Python environment variables
        cmd_line.append('-E')
    # Need to preserve the original environment, for in-place testing of
    # shared library builds.
    env = os.environ.copy()
    # But a special flag that can be set to override -- in this case, the
    # caller is responsible to pass the full environment.
    if env_vars.pop('__cleanenv', None):
        env = {}
    env.update(env_vars)
    cmd_line.extend(args)
    p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                         env=env)
    try:
        out, err = p.communicate()
    finally:
        subprocess._cleanup()
        p.stdout.close()
        p.stderr.close()
    rc = p.returncode
    err = strip_python_stderr(err)
    return _PythonRunResult(rc, out, err), cmd_line 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:37,代碼來源:script_helper.py

示例10: _assert_python

# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import _cleanup [as 別名]
def _assert_python(expected_success, *args, **env_vars):
    if '__isolated' in env_vars:
        isolated = env_vars.pop('__isolated')
    else:
        isolated = not env_vars
    cmd_line = [sys.executable, '-X', 'faulthandler']
    if isolated and sys.version_info >= (3, 4):
        # isolated mode: ignore Python environment variables, ignore user
        # site-packages, and don't add the current directory to sys.path
        cmd_line.append('-I')
    elif not env_vars:
        # ignore Python environment variables
        cmd_line.append('-E')
    # Need to preserve the original environment, for in-place testing of
    # shared library builds.
    env = os.environ.copy()
    # But a special flag that can be set to override -- in this case, the
    # caller is responsible to pass the full environment.
    if env_vars.pop('__cleanenv', None):
        env = {}
    env.update(env_vars)
    cmd_line.extend(args)
    p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                         env=env)
    try:
        out, err = p.communicate()
    finally:
        subprocess._cleanup()
        p.stdout.close()
        p.stderr.close()
    rc = p.returncode
    err = strip_python_stderr(err)
    if (rc and expected_success) or (not rc and not expected_success):
        raise AssertionError(
            "Process return code is %d, "
            "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))
    return rc, out, err 
開發者ID:hhstore,項目名稱:annotated-py-projects,代碼行數:40,代碼來源:test_support.py


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