[Baypiggies] Help ! How to exchange python objects between two python processes on the same machine ?

Joshua Gallagher joshua.gallagher at gmail.com
Fri Jul 10 02:40:44 CEST 2009


You running on Unix?  A named pipe sounds like just what you need.
os.mkfifo()
Then, open it for read from process 1.  Next, open it for write in
process 2.  Write some data from process 2 and immediately read it
from process 1.

Reference:
http://docs.python.org/library/os.html

Joshua

On Thu, Jul 9, 2009 at 5:03 PM, David Berthelot<d_berthelot at yahoo.com> wrote:
> Ok, I'm trying to send some python objects from one Python process to
> another, on the same machine.
>
> The problem is well defined and simple:
> 1. There are only 2 processes: 1 is always waiting, 1 is always sending.
> 2. As soon as a datastructure is fully sent by process1, process2 must
> receive it immediately (I mean there must be no buffering)
> 3. The processes can be given some data when they start (for example a port
> or something of that nature, or a filename).
> 4. They're on the same machine
>
> So technically I'd like to do:
> Process1: data = ((1,2,"abc",{d:"ef"}),2)
>                 send(data)
>
> Process2: data = receive();
>                 print data # And here you get the data sent by process1 (and
> note it's a python object, tuple, dict ...)
>
> I'd like to know if there's an elegant way to do this in Python, I did a
> google search but I keep running into server/clients for exchanging HTTP or
> other internet stuff which is not really what I'm looking for.
>
> Thanks,
>
> David
>
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
>


More information about the Baypiggies mailing list