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


Python Popen.terminate方法代码示例

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


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

示例1: DummySim

# 需要导入模块: from subprocess32 import Popen [as 别名]
# 或者: from subprocess32.Popen import terminate [as 别名]
class DummySim(ProcessWorkerThread):

    def handle_eval(self, record):
        self.process = Popen(['./sumfun_ext', array2str(record.params[0])],
                             stdout=PIPE)

        val = np.nan
        # Continuously check for new outputs from the subprocess
        while True:
            output = self.process.stdout.readline()
            if output == '' and self.process.poll() is not None:  # No new output
                break
            if output:  # New intermediate output
                try:
                    val = float(output.strip())  # Try to parse output
                    if val > 350:  # Terminate if too large
                        self.process.terminate()
                        self.finish_success(record, 350)
                        return
                except ValueError:  # If the output is nonsense we terminate
                    logging.warning("Incorrect output")
                    self.process.terminate()
                    self.finish_failure(record)
                    return

        rc = self.process.poll()  # Check the return code
        if rc < 0 or np.isnan(val):
            logging.warning("Incorrect output or crashed evaluation")
            self.finish_failure(record)
        else:
            self.finish_success(record, val)
开发者ID:NoobSajbot,项目名称:pySOT,代码行数:33,代码来源:test_subprocess_partial_info.py

示例2: terminate

# 需要导入模块: from subprocess32 import Popen [as 别名]
# 或者: from subprocess32.Popen import terminate [as 别名]
 def terminate(self):
     """Terminates the process"""
     # Don't terminate a process that we know has already died.
     if self.returncode is not None:
         return
     if self._job:
         winprocess.TerminateJobObject(self._job, 127)
         self.returncode = 127
     else:
         Popen.terminate(self)
开发者ID:SublimeCodeIntel,项目名称:codeintel,代码行数:12,代码来源:process.py

示例3: raw_input

# 需要导入模块: from subprocess32 import Popen [as 别名]
# 或者: from subprocess32.Popen import terminate [as 别名]
stream = raw_input("Should I stream video or take pictures (v/p)? ")
preview = raw_input("Should I display video preview on Pi (y/n)? ")

print "Running..."

#http://www.raspberry-projects.com/pi/pi-hardware/raspberry-pi-camera/streaming-video-using-vlc-player
#http://www.diveintopython.net/scripts_and_streams/stdin_stdout_stderr.html
#Ouput video (record) => stream => stdout => | => cvlc livestream => browser

if (stream == "v" or stream == "V"):
	try:
		live = Popen(["./livestream.sh"])
	finally:
		print "\n\nExiting..."
		live.terminate()
elif (stream == "p" or stream == "P"):
	length = float(raw_input("How long should I run (in minutes): "))*60
	interval = float(raw_input("How often should I take a picture (in seconds): "))
	
	camera = PiCamera()
	camera.annotate_background = picamera.Color('black')
	camera.rotation = 180
	camera.resolution = (640, 480)
	
	counter = 0
	
	try:
		if (preview == "y" or preview == "Y"):
			camera.start_preview()
		while (counter <= length):
开发者ID:benbroce3,项目名称:PiCamServer,代码行数:32,代码来源:camerav4.py


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