Inter-process communication, how?

ecir.hana at gmail.com ecir.hana at gmail.com
Sat Dec 15 22:34:37 EST 2007


On Dec 16, 2:42 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
>
>         Have you perused and been perplexed by the "Is Python a Scripting
> Language" thread? <G>

Oh, no!! Script as in "shell script".


>
> Question:       Are you creating both scripts from scratch?
> Yes?

Yes.


Then you can define whatever protocol is needed for your usage and
> is available on your OS.
>
>         If it is a one-shot (spawn sub, wait, retrieve results) you could
> generate a temporary file name in the parent, pass that name to the sub
> when invoking it, wait for the sub to complete (giving you a status
> code) and then read the result the sub has written to the file.

Yes, it's once shot. But how do I pass "that name"?
>From all the arguments of class Popen (http://docs.python.org/lib/
node529.html) perhaps I could use "env" only. Or am I wrong?
TCP/IP sounds good but isn't it a bit too heavy?
And what the other options goes I would prefer a cross platform
solution, if there is one.

PS: both with mmpam and temp file you probably meant that I should
hard code some as-weirdest-filename-as-possible two both programs but
what if I run the computation several times?

And thanks for reply!


>
>         Or, you could have parent and sub both mmap the same "file",
> essentially passing data in memory unless it becomes too large and pages
> out to swap disk. You might even be able to do bidirectional and dynamic
> updates (rather than waiting for the sub to exit)... Define, say, an
> epoch count for each process -- these would be the first two words of
> the mmap file
>
> |p-epoch|s-epoch|n-words of p-data (fixed constant known to both)|n-words of s-data|
>
> periodically the parent would examine the value of s-epoch, and if it
> has changed, read the s-data.. (both sides write the data first, then
> update the epoch count). When the epoch stays the same and two
> consecutive reads of the data match, you have stable data (so the reads
> should occur more often than updates) and can process the data
> transferred.
>
>         OR, you could have the parent open a TCP/IP socket as a server, and
> pass the socket port number to the sub. The sub would then connect to
> that port and write the data. For bidirectional you could pass the
> parent port, and the sub's first action is to connect and pass a port
> that it will be monitoring.
>
>         On a VMS system, the processes would connect to named "mailboxes"
> and use QIO operations to pass data between them.
>
>         On an Amiga you'd use "message ports" (which operated somewhat
> similar to VMS mailboxes except that mailboxes had an independent
> existence, multiple processes can read or write to them -- message ports
> were readable by the creating process, but could have messages sent from
> anywhere; typically passing the message port [address of a linked list
> of messages] for replies). Or a higher level message port: an ARexx
> port.
>
>         On a Windows NT class system, the win32 extensions allow access to
> Windows Named Pipes... Or maybe the Windows clipboard could be used...
> --
>         Wulfraed        Dennis Lee Bieber               KD6MOG
>         wlfr... at ix.netcom.com             wulfr... at bestiaria.com
>                 HTTP://wlfraed.home.netcom.com/
>         (Bestiaria Support Staff:               web-a... at bestiaria.com)
>                 HTTP://www.bestiaria.com/




More information about the Python-list mailing list