[Python-ideas] Adding shm_open to mmap?

Sturla Molden sturla at molden.no
Thu Feb 16 16:27:24 CET 2012


On 16.02.2012 02:40, Sturla Molden wrote:
>
>>
>> P.S. I have posted a possible implementation of shm_open/shm_unlink for Windows at
>>
>> http://mail.python.org/pipermail/concurrency-sig/2012-February/000058.html
>>
>>
>
> A temporary file is not backed shared memory on Windows, but is a persistent file on disk. You have to mmap from the OS' paging file to get shared memory.


Hmm...

It seems files created with the flag FILE_ATTRIBUTE_TEMPORARY is backed 
by memory if possible. Though MSDN does not say if it is shared memory 
that can be used for IPC. A blog article on MSDN from 2004 indicates 
that the combination FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE 
is needed. The  Windows systems programming book from MS Press does not 
mention FILE_ATTRIBUTE_TEMPORARY for temporary files.

So it seems most Windows programmers are actually creating permanent 
files in the temp file folder, rather than creating temporary files. So 
the cause for buil-up of temporary files on Windows is actually a 
wide-spread programming error, not the fault of the operating system.

It seems tmpfile.NamedTemporaryFile will use FILE_ATTRIBUTE_TEMPORARY on 
Windows if called with delete=True. But is does not use 
FILE_FLAG_DELETE_ON_CLOSE as well, which probably is an error 
(particularly if the "delete" keyword argument should make sence).



Sturla






More information about the Python-ideas mailing list