def remover()

in antlir/rpm/storage/cli_object_storage.py [0:0]


    def remover(self) -> ContextManager[_StorageRemover]:
        rm = _StorageRemover(storage=self, procs=[])
        try:
            # pyre-fixme[7]: Expected `ContextManager[_StorageRemover]` but got
            #  `Generator[_StorageRemover, None, None]`.
            yield rm
        finally:
            last_ex = None  # We'll re-raise the last exception.
            for proc in rm.procs:
                # Ensure we wait for each process, no matter what.
                try:
                    assert proc.returncode is None  # Not yet waited for
                    proc.wait()
                # Unit-testing this error-within-error case is hard, but all
                # it would verify is that we properly re-raise `ex`.  I
                # tested this by hand in an interpreter, see P60127851.
                except Exception as ex:  # pragma: no cover
                    last_ex = ex
            # Raise the **last** of the "wait()" exceptions.
            if last_ex is not None:  # pragma: no cover
                raise last_ex
            # Check return codes after all processes have been waited for to
            # avoid creating zombies in the event that the caller catches.
            for proc in rm.procs:
                check_popen_returncode(proc)