I am trying to modify a python program to be able to communicate with a C++ program using shared memory. The main responsibility of the python program is to read some video
Perhaps shmget and shmat are not necessarily the most appropriate interfaces for you to be using. In a project I work on, we provide access to a daemon via a C and Python API using memory mapped files, which gives us a very fast way of accessing data
The order of operations goes somewhat like this:
door_call() to tell the daemon to create a shared memory regionopen()s and then mmap()s that filedoor_return()mmap()s the file descriptor and associates consecutively-placed variables in a structure with that fdOur clients make use of a library to handle the first 5 steps above; the library comes with Python wrappers using ctypes to expose exactly which functions and data types are needed.
For your problem space, if it's just the python app which writes to your output queue then you can track which frames have been processed just in the python app. If both your python and c++ apps are writing to the output queue then that increases your level of difficulty and perhaps refactoring the overall application architecture would be a good investment.