@contextlib.contextmanager<EOL>def clean_path_on_failure(path):
try:<EOL><INDENT>yield<EOL><DEDENT>except BaseException:<EOL><INDENT>if os.path.exists(path):<EOL><INDENT>rmtree(path)<EOL><DEDENT>raise<EOL><DEDENT>
Cleans up the directory on an exceptional failure.