Wait for the subprocess to finish.

        Returns the exit code.
541858
def wait(self):
        '''
        '''
        status = self.proc.wait()
        if status >= 0:
            self.exitstatus = status
            self.signalstatus = None
        else:
            self.exitstatus = None
            self.signalstatus = -status
        self.terminated = True
        return status
31179
def block(self, warn_only=False):
        """"""
        self._state = "not finished"
        if self._return_code is None:
            proc = subprocess.Popen(
                self.cmd, cwd=self.cwd, env=self.env,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE
            )
            self._stdout, self._stderr = proc.communicate(timeout=self.timeout)
            self._return_code = proc.returncode

        self._state = FINISHED
        if not warn_only:
            self.raise_for_error()
187084
async def terminate(self):
        """"""
        # Workaround for pylint issue #1469
        # (https://github.com/PyCQA/pylint/issues/1469).
        cmd = await subprocess.create_subprocess_exec(  # pylint: disable=no-member
            *shlex.split('{} rm -f {}'.format(self.command, self._generate_container_name()))
        )
        await cmd.wait()
        await self.proc.wait()

        await super().terminate()
868468
def completed_task(self):
        
        # If its remote and finished running
        if self.remote_channel and self.remote_channel.exit_status_ready():
            # Collect all remaining stdout/stderr
            while self.remote_channel.recv_ready():
                self.stdout += self.remote_channel.recv(1024)
            while self.remote_channel.recv_stderr_ready():
                self.stderr += self.remote_channel.recv_stderr(1024)
            return self.remote_channel.recv_exit_status()
        # Otherwise check for finished local command
        elif self.process:
            self.stdout, self.stderr = (self._read_temp_file(self.stdout_file),
                                        self._read_temp_file(self.stderr_file))
            for temp_file in [self.stdout_file, self.stderr_file]:
                temp_file.close()
            return self.process.returncode
976349
def __exitfunction(self):
        '''
        
        '''
        if self._hook.exit_code is None and self._hook.exception is None:
            print("Check did not exit! You should call an exit code method.")
            sys.stdout.flush()
            os._exit(1)
        elif self._hook.exception:
            print("Check failed to run: %s, %s" %
                  (sys.last_type, traceback.format_tb(sys.last_traceback)))
            sys.stdout.flush()
            os._exit(2)
401907
def wait_for_completion(self, interval=1):
        

        while not self.is_terminated(retry=True):
            try:
                time.sleep(interval)
            except KeyboardInterrupt:
                break
915182
async def wait_and_quit(loop):
	""""""
	from pylp.lib.tasks import running
	if running:
		await asyncio.wait(map(lambda runner: runner.future, running))
863514
def on_exit(self):
        ''''''

        if not all([self.auto_write, self.commands, self.script, self.path]):
            return

        self.write()
322312
def pipe_wait(popens):
    
    # Avoid mutating the passed copy
    popens = copy.copy(popens)
    results = [0] * len(popens)
    while popens:
        last = popens.pop(-1)
        results[len(popens)] = last.wait()
    return results
243339
def stop(self):
        
        self.child.terminate()
        self._cleanup()
        return self.child.exitcode
1160395
def terminate(self, wait=False):
        """"""
        if self.proc is not None:
            self.proc.stdout.close()
            try:
                self.proc.terminate()
            except ProcessLookupError:
                pass
            if wait:
                self.proc.wait()
1295300
def stop(self) -> None:
        
        if not self.running:
            return
        try:
            self.wait(timeout_s=0)
            # If we get here: stopped already
        except subprocess.TimeoutExpired:  # still running
            for kill_level in self.ALL_KILL_LEVELS:
                tried_to_kill = self._terminate(level=kill_level)  # please stop
                if tried_to_kill:
                    try:
                        self.wait(timeout_s=self.kill_timeout_sec)
                        break
                    except subprocess.TimeoutExpired:  # failed to close
                        self.warning("Subprocess didn't stop when asked")
                        pass  # carry on escalating
        self.close_logs()
        self.running = False
1216981
def wait(self, timeout=None):
        
        # The 'or' part is for Python 2.6
        result = self.__event.wait(timeout)
        # pylint: disable=E0702
        # Pylint seems to miss the "is None" check below
        if self.__exception is None:
            return result
        else:
            raise self.__exception
520090
def wait(*args)
      pattern = args.pop
      unless pattern
        raise ArgumentError, 'Please provide condition to wait for'
      end

      run(*args) do |out, _|
        raise if out =~ /#{pattern}/
      end
    rescue ExitError
      # noop
    end
1121418
async def terminate(self):
        """"""
        self.proc.terminate()

        await asyncio.wait_for(self.proc.wait(), self.kill_delay)
        if self.proc.returncode is None:
            self.proc.kill()
        await self.proc.wait()

        await super().terminate()
266351
def _finish(self):
        
        if self._process.returncode is None:
            self._process.stdin.flush()
            self._process.stdin.close()
            self._process.wait()
            self.closed = True
782074
def run_command_for_code(command):
    
    process = subprocess.Popen(
        command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
    )
    process.communicate()
    exit_code = process.returncode
    return exit_code