[SciPy-user] shared memory machines

Sturla Molden sturla@molden...
Wed Feb 11 07:51:38 CST 2009

You need to do

if __name__ == "__main__":

in you testing code for multiprocessing to work correctly. Leaving it 
out is a source of mysterious errors. In fact on Windows, leaving it out 
creates something similar to a fork bomb.

> So I am wondering if we are not being tricked by the fact that Python
> calls the __del__ method lazily, in particular when quitting. Maybe the
> solution to this problem is to add an exit hook (seems like that's what
> other people did when faced with this problem:
> http://www.python.org/search/hypermail/python-recent/0635.html, follow up
> is also interresting:
> http://www.python.org/search/hypermail/python-recent/0636.html), however
> this is not terribly robust. I wonder how mutliprocessing deals with this
> problem.

multiprocessing.util.Finalize is an exit hook. That should do the 
clean-up in the main program. It clean up the BufferWrapper object, 
which owns the SharedMemoryBuffer.

As long as the Heap object is destroyed, it will clean up. Try to put in 
some printing to see if the buffer is marked for removal. Do not use a 
Cython's print statement but something else (e.g. printf from stdio.h).


More information about the SciPy-user mailing list