# Buggy code
def _check_failure_status(self) -> None:
    """Check the status of command failures. Raise exceptions as necessary

    The failure status property is used by the various asynchronous
    command execution threads which interface with the
    remote browser manager processes. If a failure status is found, the
    appropriate steps are taken to gracefully close the infrastructure
    """
    self.logger.debug("Checking command failure status indicator...")
    if not self.failure_status:
        return

    self.logger.debug("TaskManager failure status set, halting command execution.")
    self._shutdown_manager()
    if self.failure_status["ErrorType"] == "ExceedCommandFailureLimit":
        raise CommandExecutionError(
            "TaskManager exceeded maximum consecutive command execution failures.",
            self.failure_status["CommandSequence"],
        )
    elif self.failure_status["ErrorType"] == ("ExceedLaunchFailureLimit"):
        raise CommandExecutionError(
            "TaskManager failed to launch browser within allowable failure limit.",
            self.failure_status["CommandSequence"],
        )
    if self.failure_status["ErrorType"] == "CriticalChildException":
        exc = pickle.loads(self.failure_status["Exception"])
        assert type(exc) == BaseException, (
            "Unexpected object passed in place of exception while handling"
            " a critical exception in a child process. Please report this "
            "error to https://github.com/mozilla/OpenWPM/issues/547. "
            f"Object was of type {type(exc)} and looked like {exc!r}."
        )
        raise exc


# Traceback (TypeError)
Traceback (most recent call last):
File "collect_links.py", line 55, in <module>
manager.execute_command_sequence(command_sequence)
File "<path>OpenWPM/automation/TaskManager.py", line 565, in execute_command_sequence
self._distribute_command(command_sequence, index)
File "<path>OpenWPM/automation/TaskManager.py", line 334, in _distribute_command
thread = self._start_thread(browser, command_seq)
File "<path>OpenWPM/automation/TaskManager.py", line 395, in _start_thread
self._check_failure_status()
File "<path>OpenWPM/automation/TaskManager.py", line 301, in _check_failure_status
raise pickle.loads(self.failure_status['Exception'])
TypeError: exceptions must derive from BaseException

# Fixed code
def _check_failure_status(self) -> None:
    """Check the status of command failures. Raise exceptions as necessary

    The failure status property is used by the various asynchronous
    command execution threads which interface with the
    remote browser manager processes. If a failure status is found, the
    appropriate steps are taken to gracefully close the infrastructure
    """
    self.logger.debug("Checking command failure status indicator...")
    if not self.failure_status:
        return

    self.logger.debug("TaskManager failure status set, halting command execution.")
    self._shutdown_manager()
    if self.failure_status["ErrorType"] == "ExceedCommandFailureLimit":
        raise CommandExecutionError(
            "TaskManager exceeded maximum consecutive command execution failures.",
            self.failure_status["CommandSequence"],
        )
    elif self.failure_status["ErrorType"] == ("ExceedLaunchFailureLimit"):
        raise CommandExecutionError(
            "TaskManager failed to launch browser within allowable failure limit.",
            self.failure_status["CommandSequence"],
        )
    if self.failure_status["ErrorType"] == "CriticalChildException":
        exc_type, exc, tb = pickle.loads(self.failure_status["Exception"])
        raise exc.with_traceback(tb)