Bidrectional Subprocess Communication

Emanuele D'Arrigo manu3d at
Sun Dec 14 12:37:38 CET 2008

On Dec 14, 4:48 am, "Gabriel Genellina" <gagsl-... at>
> - you have to close server.stdin when you don't have more data to send.
> The server will see an end-of-file and knows it has to exit the loop.
> Same thing on the client side.

Hi Gabriel, thanks for modifying the code to make it work. I've just
tried tinkering with it to see how far it would go. On your two
statements above: does this means that any data must be sent in one
batch and then the subprocess must shut down? What I was trying to
simulate is a client/server relationship through a subprocess, where
the server (the subprocess) keeps listening and the client sends data
when it wants to (and eventually viceversa). But when the
server.stdin.close() statement is issued, the pipe is closed for good
and can't be reopened (can it?).

> - you have to wait until the server answers, else it will get a "broken
> pipe" error or similar.

So, if I want to interrogate the subprocess multiple times I must end
and restart the ListenerThread multiple times then?

In the meantime, I better brush up on my streams... =)

Thanks for your help!


More information about the Python-list mailing list