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


Python Subprocess.initialize方法代碼示例

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


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

示例1: test_sigchild

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_sigchild(self):
        # Twisted's SIGCHLD handler and Subprocess's conflict with each other.
        skip_if_twisted()
        Subprocess.initialize(io_loop=self.io_loop)
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, '-c', 'pass'],
                             io_loop=self.io_loop)
        subproc.set_exit_callback(self.stop)
        ret = self.wait()
        self.assertEqual(ret, 0)
        self.assertEqual(subproc.returncode, ret) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:13,代碼來源:process_test.py

示例2: test_sigchild_future

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_sigchild_future(self):
        skip_if_twisted()
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, '-c', 'pass'])
        ret = yield subproc.wait_for_exit()
        self.assertEqual(ret, 0)
        self.assertEqual(subproc.returncode, ret) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:10,代碼來源:process_test.py

示例3: test_sigchild_signal

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_sigchild_signal(self):
        skip_if_twisted()
        Subprocess.initialize(io_loop=self.io_loop)
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, '-c',
                              'import time; time.sleep(30)'],
                             io_loop=self.io_loop)
        subproc.set_exit_callback(self.stop)
        os.kill(subproc.pid, signal.SIGTERM)
        ret = self.wait()
        self.assertEqual(subproc.returncode, ret)
        self.assertEqual(ret, -signal.SIGTERM) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:14,代碼來源:process_test.py

示例4: test_wait_for_exit_raise

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_wait_for_exit_raise(self):
        skip_if_twisted()
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, '-c', 'import sys; sys.exit(1)'])
        with self.assertRaises(subprocess.CalledProcessError) as cm:
            yield subproc.wait_for_exit()
        self.assertEqual(cm.exception.returncode, 1) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:10,代碼來源:process_test.py

示例5: test_wait_for_exit_raise_disabled

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_wait_for_exit_raise_disabled(self):
        skip_if_twisted()
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, '-c', 'import sys; sys.exit(1)'])
        ret = yield subproc.wait_for_exit(raise_error=False)
        self.assertEqual(ret, 1) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:9,代碼來源:process_test.py

示例6: test_sigchild

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_sigchild(self):
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, "-c", "pass"])
        subproc.set_exit_callback(self.stop)
        ret = self.wait()
        self.assertEqual(ret, 0)
        self.assertEqual(subproc.returncode, ret) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:10,代碼來源:process_test.py

示例7: test_sigchild_future

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_sigchild_future(self):
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, "-c", "pass"])
        ret = yield subproc.wait_for_exit()
        self.assertEqual(ret, 0)
        self.assertEqual(subproc.returncode, ret) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:9,代碼來源:process_test.py

示例8: test_sigchild_signal

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_sigchild_signal(self):
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess(
            [sys.executable, "-c", "import time; time.sleep(30)"],
            stdout=Subprocess.STREAM,
        )
        self.addCleanup(subproc.stdout.close)
        subproc.set_exit_callback(self.stop)
        os.kill(subproc.pid, signal.SIGTERM)
        try:
            ret = self.wait(timeout=1.0)
        except AssertionError:
            # We failed to get the termination signal. This test is
            # occasionally flaky on pypy, so try to get a little more
            # information: did the process close its stdout
            # (indicating that the problem is in the parent process's
            # signal handling) or did the child process somehow fail
            # to terminate?
            fut = subproc.stdout.read_until_close()
            fut.add_done_callback(lambda f: self.stop())  # type: ignore
            try:
                self.wait(timeout=1.0)
            except AssertionError:
                raise AssertionError("subprocess failed to terminate")
            else:
                raise AssertionError(
                    "subprocess closed stdout but failed to " "get termination signal"
                )
        self.assertEqual(subproc.returncode, ret)
        self.assertEqual(ret, -signal.SIGTERM) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:33,代碼來源:process_test.py

示例9: test_wait_for_exit_raise

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_wait_for_exit_raise(self):
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, "-c", "import sys; sys.exit(1)"])
        with self.assertRaises(subprocess.CalledProcessError) as cm:
            yield subproc.wait_for_exit()
        self.assertEqual(cm.exception.returncode, 1) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:9,代碼來源:process_test.py

示例10: test_wait_for_exit_raise_disabled

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_wait_for_exit_raise_disabled(self):
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, "-c", "import sys; sys.exit(1)"])
        ret = yield subproc.wait_for_exit(raise_error=False)
        self.assertEqual(ret, 1) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:8,代碼來源:process_test.py

示例11: test_sigchild

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_sigchild(self):
        # Twisted's SIGCHLD handler and Subprocess's conflict with each other.
        skip_if_twisted()
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, '-c', 'pass'])
        subproc.set_exit_callback(self.stop)
        ret = self.wait()
        self.assertEqual(ret, 0)
        self.assertEqual(subproc.returncode, ret) 
開發者ID:tp4a,項目名稱:teleport,代碼行數:12,代碼來源:process_test.py

示例12: test_sigchild_signal

# 需要導入模塊: from tornado.process import Subprocess [as 別名]
# 或者: from tornado.process.Subprocess import initialize [as 別名]
def test_sigchild_signal(self):
        skip_if_twisted()
        Subprocess.initialize()
        self.addCleanup(Subprocess.uninitialize)
        subproc = Subprocess([sys.executable, '-c',
                              'import time; time.sleep(30)'],
                             stdout=Subprocess.STREAM)
        self.addCleanup(subproc.stdout.close)
        subproc.set_exit_callback(self.stop)
        os.kill(subproc.pid, signal.SIGTERM)
        try:
            ret = self.wait(timeout=1.0)
        except AssertionError:
            # We failed to get the termination signal. This test is
            # occasionally flaky on pypy, so try to get a little more
            # information: did the process close its stdout
            # (indicating that the problem is in the parent process's
            # signal handling) or did the child process somehow fail
            # to terminate?
            subproc.stdout.read_until_close(callback=self.stop)
            try:
                self.wait(timeout=1.0)
            except AssertionError:
                raise AssertionError("subprocess failed to terminate")
            else:
                raise AssertionError("subprocess closed stdout but failed to "
                                     "get termination signal")
        self.assertEqual(subproc.returncode, ret)
        self.assertEqual(ret, -signal.SIGTERM) 
開發者ID:tp4a,項目名稱:teleport,代碼行數:31,代碼來源:process_test.py


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