Reputation: 500347
Is there a Python module that would enable me to place instances of non-trivial user classes into shared memory?
By that I mean allocating directly in shared memory as opposed to pickling into and out of it.
multiprocessing.Value
and multiprocessing.Array
wouldn't work for my use case as they only seem to support primitive types and arrays thereof.
The only thing I've found so far is POSH, but it hasn't changed in eight years. This suggests that it's either super-stable or is out of date. Before I invest time in trying to get it work, I'd like to know if there are alternatives I haven't discovered yet.
I only need this to work on Linux.
Upvotes: 14
Views: 1302
Reputation: 25220
That's kind of a tough one. The best solution I can think of is pickling your objects and using a c_char_p with multiprocessing.sharedctypes. You'd still have to make sure no null bytes got into the c_char_p, either by escaping them or converting to hex.
On second thought, maybe you should go with POSH.
Upvotes: 1