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


Python Subprocess.initialize方法代码示例

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


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

示例1: 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:conn4575,项目名称:tornado,代码行数:31,代码来源:process_test.py

示例2: 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:conn4575,项目名称:tornado,代码行数:9,代码来源:process_test.py

示例3: 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:bdarnell,项目名称:tornado,代码行数:9,代码来源:process_test.py

示例4: 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:bdarnell,项目名称:tornado,代码行数:9,代码来源:process_test.py

示例5: 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:conn4575,项目名称:tornado,代码行数:10,代码来源: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:bdarnell,项目名称:tornado,代码行数:10,代码来源:process_test.py

示例7: 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:conn4575,项目名称:tornado,代码行数:12,代码来源: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):
     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:joshleeb,项目名称:PerfectGift,代码行数:12,代码来源:process_test.py

示例9: 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:bdarnell,项目名称:tornado,代码行数:8,代码来源:process_test.py


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