def METHOD_NAME(self) -> Optional[int]:
    if not self.isFinished():
        raise Exception("Cannot get return code before process is finished.")
    assert self._process is not None, "Unexpected self._process is None even though it is finished."
    return self._process.returncode