This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author riccardomurri
Recipients josh.r, riccardomurri
Date 2019-03-25.15:53:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1553529203.63.0.587961025802.issue36422@roundup.psfhosted.org>
In-reply-to
Content
> 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).
History
Date User Action Args
2019-03-25 15:53:23riccardomurrisetrecipients: + riccardomurri, josh.r
2019-03-25 15:53:23riccardomurrisetmessageid: <1553529203.63.0.587961025802.issue36422@roundup.psfhosted.org>
2019-03-25 15:53:23riccardomurrilinkissue36422 messages
2019-03-25 15:53:23riccardomurricreate