Riccardo Murri <riccardo.mu...@gmail.com> added the comment:
> you should be handling errors properly in the first place, > e.g. by changing your mount_sshfs manager to: > > @contextmanager > def mount_sshfs(localdir, remote): > subprocess.run(f"sshfs {remote} {localdir}") > try: > yield > finally: > subprocess.run(f"fusermount -u {localdir}", check=True) > > so it actually performed the guaranteed cleanup you expected from it. This would fix the case where errors occur in the "yield" part of the `mount_sshfs` context manager, but would not protect from errors *in the `fusermount -u` call itself*: if `fusermount -u` fails and throws an exception, the entire mounted filesystem will be erased. I would contend that, in general, `TemporaryDirectory.cleanup()` should stop at filesystem boundaries and not descend filesystems mounted in the temporary directory tree (whether the mount has been done via a context manager as in the example above or by any other means is irrelevant). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36422> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com