Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sharing objects in multiple processes
#1
Here's a python package I made for sharing complex objects between processes.

git: https://github.com/dRoje/pipe-proxy

The idea is you create a proxy for your object and pass it to a process. Then you use the proxy like you have a reference to the original object. Although you can only use method calls, so accessing object variables is done threw setters and getters.

Say we have an object called ‘example’, creating proxy and proxy listener is easy:

from pipeproxy import proxy 
example = Example() 
exampleProxy, exampleProxyListener = proxy.createProxy(example)
Now you send the proxy to another process.

p = Process(target=someMethod, args=(exampleProxy,)) p.start()
Use it in the other process as you would use the original object (example):

def someMethod(exampleProxy):
    ...
    exampleProxy.originalExampleMethod()
    ...
But you do have to listen to it in the main process:
exampleProxyListener.listen()
Read more and find examples here:

http://matkodjipalo.com/index.php/2017/1...rocessing/
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)