当前位置: 首页>>代码示例>>Python>>正文


Python Subprocess.uninitialize方法代码示例

本文整理汇总了Python中tornado.process.Subprocess.uninitialize方法的典型用法代码示例。如果您正苦于以下问题:Python Subprocess.uninitialize方法的具体用法?Python Subprocess.uninitialize怎么用?Python Subprocess.uninitialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.process.Subprocess的用法示例。


在下文中一共展示了Subprocess.uninitialize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tearDown

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [as 别名]
def tearDown(self):
        # Clean up Subprocess, so it can be used again with a new ioloop.
        Subprocess.uninitialize()
        self.io_loop.clear_current()
        if (not IOLoop.initialized() or
                self.io_loop is not IOLoop.instance()):
            # Try to clean up any file descriptors left open in the ioloop.
            # This avoids leaks, especially when tests are run repeatedly
            # in the same process with autoreload (because curl does not
            # set FD_CLOEXEC on its file descriptors)
            self.io_loop.close(all_fds=True)
        super(AsyncTestCase, self).tearDown()
        # In case an exception escaped or the StackContext caught an exception
        # when there wasn't a wait() to re-raise it, do so here.
        # This is our last chance to raise an exception in a way that the
        # unittest machinery understands.
        self.__rethrow() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:19,代码来源:testing.py

示例2: tearDown

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [as 别名]
def tearDown(self):
        # Clean up Subprocess, so it can be used again with a new ioloop.
        Subprocess.uninitialize()
        self.io_loop.clear_current()
        if not isinstance(self.io_loop, _NON_OWNED_IOLOOPS):
            # Try to clean up any file descriptors left open in the ioloop.
            # This avoids leaks, especially when tests are run repeatedly
            # in the same process with autoreload (because curl does not
            # set FD_CLOEXEC on its file descriptors)
            self.io_loop.close(all_fds=True)
        super(AsyncTestCase, self).tearDown()
        # In case an exception escaped or the StackContext caught an exception
        # when there wasn't a wait() to re-raise it, do so here.
        # This is our last chance to raise an exception in a way that the
        # unittest machinery understands.
        self.__rethrow() 
开发者ID:tp4a,项目名称:teleport,代码行数:18,代码来源:testing.py

示例3: test_sigchild

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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

示例4: test_sigchild_future

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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

示例5: test_sigchild_signal

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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

示例6: test_wait_for_exit_raise

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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

示例7: test_sigchild

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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

示例8: test_sigchild_future

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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

示例9: test_sigchild_signal

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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

示例10: test_wait_for_exit_raise

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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

示例11: test_sigchild

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [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 uninitialize [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

示例13: tearDown

# 需要导入模块: from tornado.process import Subprocess [as 别名]
# 或者: from tornado.process.Subprocess import uninitialize [as 别名]
def tearDown(self):
        # Clean up Subprocess, so it can be used again with a new ioloop.
        Subprocess.uninitialize()
        self.loop.clear_current()
        if (not IOLoop.initialized() or
                self.loop is not IOLoop.instance()):
            # Try to clean up any file descriptors left open in the ioloop.
            # This avoids leaks, especially when tests are run repeatedly
            # in the same process with autoreload (because curl does not
            # set FD_CLOEXEC on its file descriptors)
            self.loop.close(all_fds=True)
        super(TornadoFactoryConnectTest, self).tearDown() 
开发者ID:davebshow,项目名称:gremlinclient,代码行数:14,代码来源:test_tornado_PEP492.py


注:本文中的tornado.process.Subprocess.uninitialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。