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


Python CPopen.kill方法代码示例

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


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

示例1: testBrokenPipe

# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
 def testBrokenPipe(self):
     p = CPopen(["sleep", "1"])
     try:
         p.send_signal(signal.SIGPIPE)
     finally:
         p.kill()
     p.wait()
     self.assertEqual(p.returncode, -signal.SIGKILL)
开发者ID:oVirt,项目名称:cpopen,代码行数:10,代码来源:tests.py

示例2: testCloseFDs

# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
 def testCloseFDs(self):
     with open("/dev/zero") as f:
         p = CPopen(["sleep", "1"], close_fds=True)
         try:
             child_fds = set(os.listdir("/proc/%s/fd" % p.pid))
         finally:
             p.kill()
             p.wait()
         self.assertEqual(child_fds, set(["0", "1", "2"]))
开发者ID:oVirt,项目名称:cpopen,代码行数:11,代码来源:tests.py

示例3: testBrokenPipeSIGPIPERestored

# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
 def testBrokenPipeSIGPIPERestored(self):
     if not cpopen.SUPPORTS_RESTORE_SIGPIPE:
         raise SkipTest("subprocess module does not support restore_sigpipe")
     p = CPopen(["sleep", "1"], restore_sigpipe=True)
     try:
         p.send_signal(signal.SIGPIPE)
     finally:
         p.kill()
     p.wait()
     self.assertEqual(p.returncode, -signal.SIGPIPE)
开发者ID:oVirt,项目名称:cpopen,代码行数:12,代码来源:tests.py

示例4: testNoCloseFds

# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
 def testNoCloseFds(self):
     with open("/dev/zero") as f:
         p = CPopen(["sleep", "1"], close_fds=False)
         try:
             child_fds = set(os.listdir("/proc/%s/fd" % p.pid))
         finally:
             p.kill()
             p.wait()
         # We cannot know which fds will be inherited in the child since the
         # test framework may open some fds.
         self.assertTrue(str(f.fileno()) in child_fds)
开发者ID:oVirt,项目名称:cpopen,代码行数:13,代码来源:tests.py

示例5: testInheritParentFdsCloseFds

# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
 def testInheritParentFdsCloseFds(self):
     # From Python docs: If close_fds is true, all file descriptors except
     # 0, 1 and 2 will be closed before the child process is executed.
     with open("/dev/zero") as f:
         p = CPopen(["sleep", "1"], stdin=None, stdout=None, stderr=None,
                    close_fds=True)
         try:
             child_fds = set(os.listdir("/proc/%s/fd" % p.pid))
         finally:
             p.kill()
             p.wait()
     self.assertEqual(child_fds, set(["0", "1", "2"]))
开发者ID:oVirt,项目名称:cpopen,代码行数:14,代码来源:tests.py

示例6: testInheritParentFds

# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
 def testInheritParentFds(self):
     # From Python docs: With the default settings of None, no redirection
     # will occur; the child's file handles will be inherited from the
     # parent.
     with open("/dev/zero") as f:
         p = CPopen(["sleep", "1"], stdin=None, stdout=None, stderr=None,
                    close_fds=False)
         try:
             child_fds = set(os.listdir("/proc/%s/fd" % p.pid))
         finally:
             p.kill()
             p.wait()
         expected_fds = set(["0", "1", "2", str(f.fileno())])
     self.assertEqual(child_fds, expected_fds)
开发者ID:oVirt,项目名称:cpopen,代码行数:16,代码来源:tests.py


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