[SciPy-user] shared memory machines

Sturla Molden sturla@molden...
Fri Feb 6 09:51:52 CST 2009

On 2/6/2009 4:38 PM, Sturla Molden wrote:

> I have been thinking about this as well. I am mostly familiar with 
> Windows so excuse my terminology: We don't want an array to call 
> CloseHandle() on a mapped segment that another array is still using. The 
> effect would be global to the process. Thus, we would either need to 
> maintain some sort of global reference count for all mapped shared 
> resources, or make duplicates of the handle. On Windows there is a 
> function called DuplicateHandle() that will do this. I am not sure about 
> Unix.

On Unix we could possibly use a WeakValueDictionary with name as key and 
handle as value. And then let the handle object close itself when it is 
collected. So an array could first look for an open handle in the 
dictionary, before trying to map a new one. And since we are doing all 
this in Cython, the GIL will take care of the synchronization. This 
would also work on Windows, but there we have DuplicateHandle as another 


More information about the SciPy-user mailing list