def _validate_pid(self, pid): """Validate the passed pid argument""" if not pid: pids = sconf.get_pids_for_process(self._run, self.execname) if len(pids) != 1: raise RuntimeError( "There should be exactly one PID {0} for {1}".format( pids, self.execname)) return pids[0] elif self.execname: pids = sconf.get_pids_for_process(self._run, self.execname) if pid not in pids: raise RuntimeError( "PID {0} not mapped to {1}".format( pid, self.execname)) else: self.execname = sconf.get_task_name(self._run, pid) return pid