Comment #4 on issue 173 by
manuel.n...@gmail.com: cannot pickle universe
object
http://code.google.com/p/mdanalysis/issues/detail?id=173
Just to clarify the cryptic error message:
pickle checks whether a class has a __getstate__ function, and then
executes it if it does. The way this is done is a sort of duck-typing,
where object.__getstate__ is assigned to a variable, which is subsequently
called.
If there is no __getstate__ an AttributeError is raised, in which case
pickle's default behavior ensues.
The thing with some MDAnalysis onjects is that they manage their attributes
and never raise an AttributeError. In particular if you try
AtomGroup.__getstate__ you get a SelectionError which pickle does not
handle; if you do the same with Segment.__getstate__ you get no error (!!)
and an empty AtomGroup is returned. It is this last case that causes
the 'TypeError: 'AtomGroup' object is not callable' when pickle tries to
execute what it got for Segment.__getstate__.
This is a dangerous side-effect of the syntactic sugar for selection
shortcuts. A lot of things can go silently ignored.
On the topic of parallelization, I'll post soon some code I have geared
specifically for parallelizing trajectory reads. The serialization of
MDAnalysis objects only becomes a problem if they are to be passed back and
forth between workers. If the code avoids that (and takes care of renewing
file descriptors) multiprocessing works fine.