# Buggy code
def _CheckStatusAnalysisProcess(self, pid):
    """Checks the status of an analysis process.

    Args:
      pid (int): process ID (PID) of a registered analysis process.

    Raises:
      KeyError: if the process is not registered with the engine.
    """
    # TODO: Refactor this method, simplify and separate concerns (monitoring
    # vs management).
    self._RaiseIfNotRegistered(pid)

    if pid in self._completed_analysis_processes:
        status_indicator = definitions.PROCESSING_STATUS_COMPLETED
        process_status = {"processing_status": status_indicator}

    else:
        process = self._processes_per_pid[pid]

        process_status = self._GetProcessStatus(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()

        if used_memory > self._worker_memory_limit:
            logging.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.PROCESSING_STATUS_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
                logging.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.PROCESSING_STATUS_RUNNING
            else:
                processing_status_string = "killed"
                status_indicator = definitions.PROCESSING_STATUS_KILLED

            process_status = {"processing_status": processing_status_string}

    self._UpdateProcessingStatus(pid, process_status, used_memory)

    if status_indicator in definitions.PROCESSING_ERROR_STATUS:
        logging.error(
            (
                "Process {0:s} (PID: {1:d}) is not functioning correctly. "
                "Status code: {2!s}."
            ).format(process.name, pid, status_indicator)
        )

        self._TerminateProcess(pid)


# Traceback (TypeError)
Exception in thread Status update:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/plaso-1.5.2.post20170119-py2.7.egg/plaso/multi_processing/task_engine.py", line 509, in _StatusUpdateThreadMain
self._status_update_callback(self._processing_status)
File "/usr/local/lib/python2.7/dist-packages/plaso-1.5.2.post20170119-py2.7.egg/plaso/cli/status_view_tool.py", line 149, in _PrintStatusUpdate
status_row = self._FormatStatusTableRow(worker_status)
File "/usr/local/lib/python2.7/dist-packages/plaso-1.5.2.post20170119-py2.7.egg/plaso/cli/status_view_tool.py", line 111, in _FormatStatusTableRow
used_memory = self._FormatSizeInUnitsOf1024(process_status.used_memory)
File "/usr/local/lib/python2.7/dist-packages/plaso-1.5.2.post20170119-py2.7.egg/plaso/cli/status_view_tool.py", line 63, in _FormatSizeInUnitsOf1024
used_memory_1024 = float(size)
TypeError: float() argument must be a string or a number

2017-01-23 06:00:55,183 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.
2017-01-23 06:01:07,371 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.
2017-01-23 06:01:23,611 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.
2017-01-23 06:01:29,723 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.
2017-01-23 06:01:41,507 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.
2017-01-23 06:01:47,519 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.
2017-01-23 06:01:54,583 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.
2017-01-23 06:02:11,607 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.
2017-01-23 06:02:24,095 [WARNING] (MainProcess) PID:15653 <zeromq_queue> main_task_queue timeout waiting for a request.

# Fixed code
def _CheckStatusAnalysisProcess(self, pid):
    """Checks the status of an analysis process.

    Args:
      pid (int): process ID (PID) of a registered analysis process.

    Raises:
      KeyError: if the process is not registered with the engine.
    """
    # TODO: Refactor this method, simplify and separate concerns (monitoring
    # vs management).
    self._RaiseIfNotRegistered(pid)

    if pid in self._completed_analysis_processes:
        status_indicator = definitions.PROCESSING_STATUS_COMPLETED
        process_status = {"processing_status": status_indicator}

    else:
        process = self._processes_per_pid[pid]

        process_status = self._GetProcessStatus(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 used_memory > self._worker_memory_limit:
            logging.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.PROCESSING_STATUS_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
                logging.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.PROCESSING_STATUS_RUNNING
            else:
                processing_status_string = "killed"
                status_indicator = definitions.PROCESSING_STATUS_KILLED

            process_status = {"processing_status": processing_status_string}

    self._UpdateProcessingStatus(pid, process_status, used_memory)

    if status_indicator in definitions.PROCESSING_ERROR_STATUS:
        logging.error(
            (
                "Process {0:s} (PID: {1:d}) is not functioning correctly. "
                "Status code: {2!s}."
            ).format(process.name, pid, status_indicator)
        )

        self._TerminateProcess(pid)