shared memory pointer
Tim Golden
mail at timgolden.me.uk
Mon Sep 10 11:11:07 EDT 2007
Tim wrote:
> Hello Everyone,
>
> I am getting shared memory in python using the following.
>
> szName = c_char_p(name)
> hMapObject = windll.kernel32.CreateFileMappingA(INVALID_HANDLE_VALUE,
> None, PAGE_READONLY, 0, TABLE_SHMEMSIZE, szName)
> if (hMapObject == 0):
> print "OpenKey: Could not open name file mapping object"
> raise WinError()
>
> self.pData = windll.kernel32.MapViewOfFile(hMapObject,
> FILE_MAP_ALL_ACCESS, 0, 0, TABLE_SHMEMSIZE)
Without answering your question directly, why not use
the stdlib mmap module, which does exactly this for
you behind the scenes?
Docs - http://docs.python.org/lib/module-mmap.html
Example - http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413807
TJG
More information about the Python-list
mailing list