Sharing common memory space (In form of List) across the python processes.

Terry Reedy tjreedy at udel.edu
Fri Aug 1 22:55:17 CEST 2008



Piyush Chechani wrote:
> 
> Hi,
> 
> I am working on a module where I need to share contents of a big List 
> across the processes. I am using socket programming concept for this.
> 
> My current processing for this is as follows: -
>         1. There is a server program S which loads the list in the 
> memory, and listens on a particular port,
>         2. All the other programs which want to access that list sends a 
> request on that server port,
>         3. Server sends the id of the memory loaded list element to the 
> requesting process.
> Here I am getting a problem in the reverse function of id(), as my 
> client should get the list object using its id but I don't know the 
> python function for doing this.

There intentionally is no such function.  If by 'process', I believe you 
should just send the object, which actually just sends an internal 
reference to the object.  If you mean OS process, look into interprocess 
communication.  3.0 has a new multiprocessing module that might help. 
Or have your server perform manipulations on the object.




More information about the Python-list mailing list