Python Shared Memory Array, no attribute get_obj()
===

I am working on manipulating numpy arrays using the multiprocessing module and am running into an issue trying out some of the code I have run across here.  Specifically, I am creating a ctypes array from a numpy array and then trying to return the ctypes array to a numpy array.  Here is the code:

        shared_arr = multiprocessing.RawArray(_numpy_to_ctypes[array.dtype.type],array.size)

I do not need any kind of synchronization lock, so I am using RawArray.  The ctypes data type is pulled from a dictionary based on the dtype of the input array.  That is working wonderfully.


        shared_arr = numpy.ctypeslib.as_array(shared_arr.get_obj())

Here I get a stack trace stating:

        AttributeError: 'c_double_Array_16154769' object has no attribute 'get_obj'

I have also tried the following from [this post][1], but get an identical error.

        def tonumpyarray(shared_arr):
            return numpy.frombuffer(shared_arr.get_obj())  

I am stuck running python 2.6 and do not know if that is the issue, if it is an issue with sharing the variable name (I am trying to keep memory usage as low as possible and am trying not to duplicate the numpy array and the ctypes array in memory), or something else as I am just learning about this component of python.

Suggestions?


  [1]: http://stackoverflow.com/a/7908612/839375