code: def _CheckStatusAnalysisProcess(self, pid):
      self._RaiseIfNotRegistered(pid)
      if pid in self._completed_analysis_processes:
        status_indicator = definitions.STATUS_INDICATOR_COMPLETED
        process_status = {
            'processing_status': status_indicator}
        used_memory = 0
      else:
        process = self._processes_per_pid[pid]
        process_status = self._QueryProcessStatus(process)
        if process_status is None:
          process_is_alive = False
        else:
          process_is_alive = True
        process_information = self._process_information_per_pid[pid]
        used_memory = process_information.GetUsedMemory() or 0
        if self._worker_memory_limit and used_memory > self._worker_memory_limit:
          logger.warning((
              'Process: {0:s} (PID: {1:d}) killed because it exceeded the '
              'memory limit: {2:d}.').format(
                  process.name, pid, self._worker_memory_limit))
          self._KillProcess(pid)
        if isinstance(process_status, dict):
          self._rpc_errors_per_pid[pid] = 0
          status_indicator = process_status.get('processing_status', None)
          if status_indicator == definitions.STATUS_INDICATOR_COMPLETED:
            self._completed_analysis_processes.add(pid)
        else:
          rpc_errors = self._rpc_errors_per_pid.get(pid, 0) + 1
          self._rpc_errors_per_pid[pid] = rpc_errors
          if rpc_errors > self._MAXIMUM_RPC_ERRORS:
            process_is_alive = False
          if process_is_alive:
            rpc_port = process.rpc_port.value
            logger.warning((
                'Unable to retrieve process: {0:s} (PID: {1:d}) status via '
                'RPC socket: http://localhost:{2:d}').format(
                    process.name, pid, rpc_port))
            processing_status_string = 'RPC error'
            status_indicator = definitions.STATUS_INDICATOR_RUNNING
          else:
            processing_status_string = 'killed'
            status_indicator = definitions.STATUS_INDICATOR_KILLED
          process_status = {
              'processing_status': processing_status_string}
      self._UpdateProcessingStatus(pid, process_status, used_memory)
      if status_indicator in definitions.ERROR_STATUS_INDICATORS:
        logger.error((
            'Process {0:s} (PID: {1:d}) is not functioning correctly. '
            'Status code: {2!s}.').format(
                process.name, pid, status_indicator))
        self._TerminateProcessByPid(pid)