本文整理汇总了Python中Process.Process.kill方法的典型用法代码示例。如果您正苦于以下问题:Python Process.kill方法的具体用法?Python Process.kill怎么用?Python Process.kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process.Process
的用法示例。
在下文中一共展示了Process.kill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DeviceLaunchfile
# 需要导入模块: from Process import Process [as 别名]
# 或者: from Process.Process import kill [as 别名]
class DeviceLaunchfile(Device):
def __init__(self, name, path , packageName, launchfile):
super(DeviceLaunchfile, self).__init__(name, path)
self._launchFile = self._getLaunchFile(packageName, launchfile)
self._process = None
def launch(self):
# Make sure launch file exists
if self._launchFile and os.path.exists(self._launchFile):
try:
popen = subprocess.Popen(['roslaunch',
self._launchFile,
'NAMESPACE:=' + rospy.get_namespace(),
'DEVICE:=' + self._path])
self._process = Process(popen)
return True
except:
pass
return False
def kill(self):
if self._process:
self._process.kill()
@staticmethod
def _getLaunchFile(packageName, launchfile):
packageDir = None
rospack = rospkg.RosPack()
try:
packageDir = rospack.get_path(packageName)
except rospkg.ResourceNotFound:
pass
else:
return os.path.join(packageDir, 'launch', launchfile)
return None