NEWBIE: interprocess communication between Python and C

Jeff jam at quark.emich.edu
Mon Sep 20 10:40:57 EDT 1999


On Mon, Sep 20, 1999 at 01:58:16AM +0000, etsang at my-deja.com wrote:
> I want to test the App program's ability to do interprocess
> communication. The way to do this is to have my C
> driver program in one process and My App program in another process.
> But in using Python extendsion to C. How can I
> have the driving programs(python script, C wrapper program)  run in
> one process while my Apps program in another process,
> 
> Let me put in some sample code here.
> I have three files:
> 1) mymathtest.py as the python script
> 2) mymath_wrapper.c as the wrapper file to mymath.c
> 3) mymath.c is my App.
> I can have 1) and 2) in the one process, and 3) as a seperate process?
> How? Can anyone show me a concrete example, may be by modifying the
> code I have below? Thanks
> 
[..snipped..]

I looked through the code you posted.. why not use a simple text-based
protocol to talk between your applications? it might not be as byte-saving
as a binary-based protocol, but it will at least be easier to read. all you
need to do in that kind of situation is parse simple strings, and neither
side needs to worry about endianess issues.

check out 'smtp', 'nntp' and 'http', all of which have client-side python
modules that can get you started into research on how text-based protocols
work.

what kind of data are you ultimately trying to transfer back and forth? is
it all numbers, all strings, or both? what kinds of ways does each peer need
to use the data? do you need to perform calculations with your numbers, or
just display them to a user? what kinds of things are you doing with the
string data? if the strings will contain embedded newline characters (\n),
you might want to consider how to escape them.

regards,
J
-- 
|| visit gfd <http://quark.newimage.com/> 
|| psa member #293 <http://www.python.org/> 
|| New Image Systems & Services, Inc. <http://www.newimage.com/>




More information about the Python-list mailing list