I'm not sure what exactly you mean by "rides on top of" and
Do you mean having python fork and exec the existing app, writing
and reading thru pipes ?
Or do you mean embedding the existing code in the Python interpreter ?
( Or something else? )
Both of the above can be done.
The first I have done with some limited success. ( and some
failure ! ) I've gotten this to work with some progs, but
with others, it fails in various ways. With prog == None,
it should talk to another python process, but I get errors
from that process when I try to send it a simple python
command or expression.
( via. posix.write( f, '1 + 2\n' ), for example. )
def test( prog, *args ):
p = posix.pipe()
pid = posix.fork()
if pid : return p + (pid,)
posix.dup2( p, sys.stdin.fileno() )
posix.dup2( p, sys.stdout.fileno() )
if prog : return posix.execv( prog, args )
A vote is pending to create a comp.lang.python newsgroup.
In the meantime, you might want to send your questions to
the python mailing list ( email@example.com ).
I am CC-ing this message to the list - maybe someone there
will have some additional advice for YOU, or some comments
on why MY code doesn't always work.
In some simple tests, it worked for 'bc', it didn't work
at all for 'tr', and just forking another python image
gave syntax errors when it read the string. I have heard
that there are often sync problems with full duplex pipes -
I have also run into that, but THESE are different problems.
( One way communication with posix.popen() is trivially easy.)
- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics