def _close_internal(self): # Assume that when this is called, _lock should be acquired, already. if self._master_job: logging.debug('Nuking ssh master_job') utils.nuke_subprocess(self._master_job.sp) self._master_job = None if self._master_tempdir: logging.debug('Cleaning ssh master_tempdir') self._master_tempdir.clean() self._master_tempdir = None
def _cleanup_master_ssh(self): """ Release all resources (process, temporary directory) used by an active master SSH connection. """ # If a master SSH connection is running, kill it. if self.master_ssh_job is not None: utils.nuke_subprocess(self.master_ssh_job.sp) self.master_ssh_job = None # Remove the temporary directory for the master SSH socket. if self.master_ssh_tempdir is not None: self.master_ssh_tempdir.clean() self.master_ssh_tempdir = None self.master_ssh_option = ''
def _start_miniomaha(self): """ Starts a mini-Omaha server and drains its log output. """ def is_miniomaha_up(): try: utils.urlopen("http://localhost:%d" % self.miniomaha_port).read() return True except: return False assert not is_miniomaha_up() self.miniomaha_output = os.path.join(self.outputdir, "miniomaha.out") # TODO(jsalz): Add cwd to BgJob rather than including the 'cd' in the # command. bg_job = utils.BgJob( "cd %s; exec ./%s --port=%d --factory_config=miniomaha.conf" % (os.path.join(self.src_root(), os.path.dirname(_MINIOMAHA_PATH)), os.path.basename(_MINIOMAHA_PATH), self.miniomaha_port), verbose=True, stdout_tee=utils.TEE_TO_LOGS, stderr_tee=open(self.miniomaha_output, "w")) self.cleanup_tasks.append(lambda: utils.nuke_subprocess(bg_job.sp)) thread.start_new_thread(utils.join_bg_jobs, ([bg_job], )) client_utils.poll_for_condition(is_miniomaha_up, timeout=_MINIOMAHA_TIMEOUT_SEC, desc="Miniomaha server")
def kill_func(): #this triggers the remote kill utils.nuke_subprocess(job.sp)