本文整理匯總了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):