On 7 October 2014 15:58, Jed Brown <[email protected]> wrote:
>
> "Garth N. Wells" <[email protected]> writes:
> > I thought the issue we're discussing is that the above Python pattern,
> > which is the natural way to do things, can break in parallel because of
> > non-deterministic garbage collection and that we need an alternative?
>
> The with statement (PEP 343) provides __exit__, which is deterministic.
> That pattern is idiomatic and correct.  Relying on garbage collection
> when a variable falls out of scope is the problem.

Exactly. This includes the three patterns which are everywhere in dolfin
tests and demos:

File(...) << u

def f():
    file = File(...)
    file << u

def g():
    file = File(...)
    file << u
    del file

(And as Jed said I was of course wrong about RAII providing exception
safety in the MPI context).

Martin
_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics

Reply via email to