Passing python objects through interpreters

I would like to exchange objects between two python interpreters running on the same (and different) machines.

Is there a mechanism to achieve the same?

~ Vijay

To be more specific: I have few processes running on the same (and different) machine (s). Few of these processes produce objects that are consumed by other processes. I am trying to solve a producer / consumer problem among these processes.

I previously ran these processes on the same python interpreter as threads and could use queues to solve the producer-consumer problem. However, due to the increased load, I decided to transfer some processes to other machines. Now these processes, located on different machines (and translators), must share access to the queue. I would like to know if there is a mechanism that helps me do this effectively.

I could write one class that manages the queue and processes objects to / from other processes using sockets.

I think this is a common problem if you want to use python to handle large amounts of data. So I was interested to know if there are other more elegant solutions.

~ Vijay

+4
source share
2 answers

Typically, you need to serialize an object. In Python, which means pickle and uncalle. You can grind an object from one side, transfer it in some way (socket, etc.) to the other and scatter it. To do this, use pickle or cPickle .

The Pyro package is a complete package that makes it transparent.

+5
source

Use the Python brine module to serialize / deserialize the state of an object:

http://docs.python.org/library/pickle.html

+5
source

All Articles