本文整理汇总了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)
示例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)
示例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):