On Thu, Dec 5, 2013 at 10:58 AM, Thomas Thrainer <[email protected]> wrote:
> I don't quite like this 'with' construction here: It hides the fact that
> there are rather complex operations (mounting and later unmounting) are
> going on, which can even fail randomly here. Something like try-finally or
> 'with self.volume.Mount()' would make it much more readable (if I were to
> choose, I'd go for the try-finally approach). What do you think?
>
> The same holds true for all other 'with' constructs for mounting.

I personally don't think expectation of non-complexity is necessarily
there with a with statement; even just a run-of-the-mill "with
file(foo) as fobj:" line requires you to make system calls (and, with
networked file systems such as Gluster, this can be absolutely
non-trivial); otoh by using with we get guarantees from the language
that a volume unmount _will_ be tried no matter what and that
exceptions within the with: block will be handled correctly - all with
cleaner, simpler code.

-- 
Raffa Santi
Google Germany GmbH
Dienerstr. 12
80331 München


Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to