Message338806
> 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). |
|
Date |
User |
Action |
Args |
2019-03-25 15:53:23 | riccardomurri | set | recipients:
+ riccardomurri, josh.r |
2019-03-25 15:53:23 | riccardomurri | set | messageid: <1553529203.63.0.587961025802.issue36422@roundup.psfhosted.org> |
2019-03-25 15:53:23 | riccardomurri | link | issue36422 messages |
2019-03-25 15:53:23 | riccardomurri | create | |
|