writes to numpy arrays returned through py::array_t don't seem to work #3975
Unanswered
iourielementary
asked this question in
Q&A
Replies: 1 comment 1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a process that uses shared memory. The goal is to have memory allocated in shared memory and then return this memory as numpy array to calling python process.
Shared memory is managed by Boost.Interprocess. When a call is made from python to get numpy array, a tuple is created containing numpy array and Boost.Interprocess handle that identifies allocated shared memory.
This is a snippet of code where numpy array is created, inserted into tuple and returned:
On python side numpy and handle are extracted from the tuple:
The issue that I have is when new values are assigned to numpy array, they are not written to shared memory. I did a little bit of troubleshooting to confirm this:
So it looks like numpy array has changed and has new values
11,22,33
. However I need to verify that new values are written to shared memory as well.Looking at the memory mapping of the running process, I confirm that start address
0x7f74084c21e0
is indeed within shared memory.0x7f74084c21e0
, which is buffer start addressthis shows me that actual values stored in shared memory are still
1,2,3
, and new values were never written.Does anybody have an idea of what I am doing wrong here? Any comments/suggestion/queries are welcome.
Beta Was this translation helpful? Give feedback.
All reactions