[SciPy-user] shared memory machines

Philip Semanchuk philip@semanchuk....
Fri Feb 6 09:26:46 CST 2009


On Feb 6, 2009, at 10:15 AM, Sturla Molden wrote:

> On 2/6/2009 1:34 AM, Brian Granger wrote:
>
>> Can these mechanisms be used to create shared memory amongst  
>> processes
>> that are started in a completely independent manner.  That is, they
>> are not fork()'d.
>
> Yes it can. If we know the name of the segment (an integer on Unix, a
> string on Windows), it can be mapped into any process. Similarly for
> named semaphores.

A small correction -- SysV IPC objects are referred to with an integer  
key. POSIX IPC objects are referred to with a file system-ish name  
e.g. "/my_semaphore".


> The question remains: should we base this on Cython or C (there is  
> very
> little coding to do), or some third party extension, e.g. Philip
> Semanchuk's POSIX IPC and Mark Hammond's pywin32? I am thinking that  
> at
> least for POSIX IPC, GPL is a severe limitation. Also we need some
> automatic clean up, which can only be accomplished with an extension
> object (that is, __dealloc__ in Cython will always be called, as  
> opposed
> to __del__ in Python). In Pywin32 there is a PyHANDLE object that
> automatically calls CloseHandle when it is collected. But I don't  
> think
> Semanchuk's POSIX IPC module will do the same. And avoiding  
> dependencies
> on huge projects like pywin32 is also good.

You are correct that posix_ipc doesn't close handles when deallocated.  
THis is a deliberate choice -- the documentation says that closing the  
handle makes the IPC object no longer available to the *process*. So  
if one has multiple handles to an IPC object (say, inside multiple  
threads), closing one would invalidate them all. But as I write this,  
I'm wondering if that's not just a documentation bug and something  
with which I ought to experiment.


bye
Philip




More information about the SciPy-user mailing list