Shared memory python between two separate shell-launched processes
askutt at gmail.com
Fri Feb 11 12:27:28 CET 2011
On Feb 10, 9:30 am, "Charles Fox (Sheffield)" <charles.... at gmail.com>
> But when I look at posix_ipc and POSH it looks like you have to fork
> the second process from the first one, rather than access the shared
> memory though a key ID as in standard C unix shared memory. Am I
> missing something? Are there any other ways to do this?
I don't see what would have given you that impression at all, at least
with posix_ipc. It's a straight wrapper on the POSIX shared memory
functions, which can be used across processes when used correctly.
Even if for some reason that implementation lacks the right stuff,
there's always SysV IPC.
Open the same segment in both processes, use mmap, and go. What will
be tricky, of course, is binding to wherever you stuffed the
dictionary. I think ctypes.cast() can do what you need, but I've
never done it before.
Also, just FYI, there is no such thing as "standard C unix shared
memory". There are at least three different relatively widely-
supported techniques: SysV, (anonymous) mmap, and POSIX Realtime
Shared Memory (which normally involves mmap). All three are
standardized by the Open Group, and none of the three are implemented
with perfect consistency across Unicies.
More information about the Python-list