Sharing data structures between 2 Python processes
data-structures, python, python-3.x, rpc, share
Solution
If you start up the processes using multiprocessing, you're able to share `Array` and `Value` variables across the process boundary.
Check out this python doc page on using `shared memory` and `multiprocessing`
...
from multiprocessing import Process, Value, Array
def f(n, a):
n.value = 3.1415927
for i in range(len(a)):
a[i] = -a[i]
if __name__ == '__main__':
num = Value('d', 0.0)
arr = Array('i', range(10))
p = Process(target=f, args=(num, arr))
p.start()
p.join()
print(num.value)
print(arr[:])
...
Problem
I have 2 applications/process/scripts running with Python 3: there is some easy RPC mechanism to share lists, tuples and data structures between this 2 separate processes ? To be precise this 2 processes are working locally, on the same machine, but a generic solution that can also work with remote processes will be highly appreciated.