# Buggy code
def _UpdateProcessingStatus(self, pid, process_status):
    """Updates the processing status.

    Args:
      pid (int): process identifier (PID) of the worker process.
      process_status (dict[str, object]): status values received from
          the worker process.

    Raises:
      KeyError: if the process is not registered with the engine.
    """
    self._RaiseIfNotRegistered(pid)

    if not process_status:
        return

    process = self._processes_per_pid[pid]

    processing_status = process_status.get("processing_status", None)

    self._RaiseIfNotMonitored(pid)

    display_name = process_status.get("display_name", "")
    number_of_consumed_errors = process_status.get("number_of_consumed_errors", None)
    number_of_produced_errors = process_status.get("number_of_produced_errors", None)
    number_of_consumed_events = process_status.get("number_of_consumed_events", None)
    number_of_produced_events = process_status.get("number_of_produced_events", None)
    number_of_consumed_reports = process_status.get("number_of_consumed_reports", None)
    number_of_produced_reports = process_status.get("number_of_produced_reports", None)
    number_of_consumed_sources = process_status.get("number_of_consumed_sources", None)
    number_of_produced_sources = process_status.get("number_of_produced_sources", None)

    if processing_status != definitions.PROCESSING_STATUS_IDLE:
        last_activity_timestamp = process_status.get("last_activity_timestamp", 0.0)

        if last_activity_timestamp:
            last_activity_timestamp += self._PROCESS_WORKER_TIMEOUT

            current_timestamp = time.time()
            if current_timestamp > last_activity_timestamp:
                logging.error(
                    (
                        "Process {0:s} (PID: {1:d}) has not reported activity within "
                        "the timeout period."
                    ).format(process.name, pid)
                )
                processing_status = definitions.PROCESSING_STATUS_NOT_RESPONDING

    self._processing_status.UpdateWorkerStatus(
        process.name,
        processing_status,
        pid,
        display_name,
        number_of_consumed_sources,
        number_of_produced_sources,
        number_of_consumed_events,
        number_of_produced_events,
        number_of_consumed_errors,
        number_of_produced_errors,
        number_of_consumed_reports,
        number_of_produced_reports,
    )

    task_identifier = process_status.get("task_identifier", "")
    if not task_identifier:
        return

    try:
        self._task_manager.UpdateTaskByIdentifier(task_identifier)
    except KeyError:
        try:
            self._task_manager.RescheduleTaskByIdentifier(task_identifier)
        except KeyError:
            logging.error(
                "Worker processing unknown task: {0:s}.".format(task_identifier)
            )


# Traceback (WindowsError)
(plaso) C:\dev\plaso>python tools\psort.py -o xlsx G:\test_data\set_1_output.zip -w G:\test_data\set_1_output.xlsx --status_view none -d --analysis browser_search
2016-08-30 12:37:21,882 [INFO] (MainProcess) PID:9376 <psort> Starting analysis plugins.
2016-08-30 12:37:21,888 [DEBUG] (MainProcess) PID:9376 <zeromq_queue> Creating socket for browser_search output event queue
2016-08-30 12:37:21,898 [DEBUG] (MainProcess) PID:9376 <zeromq_queue> browser_search output event queue bound to random port 61649
2016-08-30 12:37:22,417 [INFO] (MainProcess) PID:9376 <psort> Started analysis plugin: browser_search (PID: 14200).
2016-08-30 12:37:24,822 [INFO] (MainProcess) PID:9376 <psort> Analysis plugins running
Traceback (most recent call last):
File "tools\psort.py", line 867, in <module>
if not Main():
File "tools\psort.py", line 853, in Main
tool.ProcessStorage()
File "tools\psort.py", line 787, in ProcessStorage
status_update_callback=status_update_callback)
File "C:\dev\plaso\plaso\frontend\psort.py", line 103, in AnalyzeEvents
status_update_callback=status_update_callback)
File "C:\dev\plaso\plaso\multi_processing\psort.py", line 536, in AnalyzeEvents
storage_writer.Open()
File "C:\dev\plaso\plaso\storage\zip_file.py", line 3217, in Open
self._storage_file.Open(path=self._output_file, read_only=False)
File "C:\dev\plaso\plaso\storage\zip_file.py", line 2754, in Open
self._OpenZIPFile(path, read_only)
File "C:\dev\plaso\plaso\storage\zip_file.py", line 1740, in _OpenZIPFile
os.rename(path, zipfile_path)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process

# Fixed code
def _UpdateProcessingStatus(self, pid, process_status):
    """Updates the processing status.

    Args:
      pid (int): process identifier (PID) of the worker process.
      process_status (dict[str, object]): status values received from
          the worker process.

    Raises:
      KeyError: if the process is not registered with the engine.
    """
    self._RaiseIfNotRegistered(pid)

    if not process_status:
        return

    process = self._processes_per_pid[pid]

    processing_status = process_status.get("processing_status", None)

    self._RaiseIfNotMonitored(pid)

    display_name = process_status.get("display_name", "")
    number_of_consumed_errors = process_status.get("number_of_consumed_errors", None)
    number_of_produced_errors = process_status.get("number_of_produced_errors", None)
    number_of_consumed_events = process_status.get("number_of_consumed_events", None)
    number_of_produced_events = process_status.get("number_of_produced_events", None)
    number_of_consumed_reports = process_status.get("number_of_consumed_reports", None)
    number_of_produced_reports = process_status.get("number_of_produced_reports", None)
    number_of_consumed_sources = process_status.get("number_of_consumed_sources", None)
    number_of_produced_sources = process_status.get("number_of_produced_sources", None)

    if processing_status != definitions.PROCESSING_STATUS_IDLE:
        last_activity_timestamp = process_status.get("last_activity_timestamp", 0.0)

        if last_activity_timestamp:
            last_activity_timestamp += self._PROCESS_WORKER_TIMEOUT

            current_timestamp = time.time()
            if current_timestamp > last_activity_timestamp:
                logging.error(
                    (
                        "Process {0:s} (PID: {1:d}) has not reported activity within "
                        "the timeout period."
                    ).format(process.name, pid)
                )
                processing_status = definitions.PROCESSING_STATUS_NOT_RESPONDING

    self._processing_status.UpdateWorkerStatus(
        process.name,
        processing_status,
        pid,
        display_name,
        number_of_consumed_sources,
        number_of_produced_sources,
        number_of_consumed_events,
        number_of_produced_events,
        number_of_consumed_errors,
        number_of_produced_errors,
        number_of_consumed_reports,
        number_of_produced_reports,
    )

    task_identifier = process_status.get("task_identifier", "")
    if not task_identifier:
        return

    try:
        self._task_manager.UpdateTaskByIdentifier(task_identifier)
    except KeyError:
        try:
            self._task_manager.RescheduleTaskByIdentifier(task_identifier)
        except KeyError:
            logging.error(
                "Worker {0:s} is processing unknown task: {1:s}.".format(
                    process.name, task_identifier
                )
            )