Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-06 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 02 Mar 2007 14:38:59 -0300, Donn Cave <[EMAIL PROTECTED]> > escribió: > > > In article <[EMAIL PROTECTED]>, > > "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > > >> On http://docs.python.org/lib/popen2

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-05 Thread Gabriel Genellina
En Fri, 02 Mar 2007 14:38:59 -0300, Donn Cave <[EMAIL PROTECTED]> escribió: > In article <[EMAIL PROTECTED]>, > "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > >> On http://docs.python.org/lib/popen2-flow-control.html there are some >> notes on possible flow control problems you may encounter.

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-02 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 01 Mar 2007 14:42:00 -0300, <[EMAIL PROTECTED]> escribió: > > > BUT If I use PIPE for both (so I can .write() on the stdin and .read() > > from the subprocess' stdout stream (better: file descriptor)) readin

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-02 Thread Bernhard Herzog
[EMAIL PROTECTED] writes: > So, once I start the C Program from the shell, I immediately get its > output in my terminal. If I start it from a subprocess in python and > use python's sys.stdin/sys.stdout as the subprocess' stdout/stdin I > also get it immediately. If stdout is connected to a term

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-02 Thread bayer . justin
> If you are both waiting for input, you have a Mexican standoff... That is not the problem. The problem is, that the buffers are not flushed correctly. It's a dialogue, so nothing complicated. But python does not get what the subprocess sends onto the subprocess' standard out - not every time, an

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-01 Thread Hendrik van Rooyen
<[EMAIL PROTECTED]> wrote: 8<-- > The C programm gets its "commands" from its stdin and sends its state > to stdout. Thus I have some kind of dialog over stdin. > > So, once I start the C Program from the shell, I immediately get its > output in my terminal. If I start it from a

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-01 Thread Hendrik van Rooyen
<[EMAIL PROTECTED]> wrote: > Hi, > > Thanks for your answer. I had a look into the fcntl module and tried > to unlock the output-file, but > > >>> fcntl.lockf(x.stdout, fcntl.LOCK_UN) > Traceback (most recent call last): > File "", line 1, in > IOError: [Errno 9] Bad file descriptor > > I

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-01 Thread Gabriel Genellina
En Thu, 01 Mar 2007 14:42:00 -0300, <[EMAIL PROTECTED]> escribió: > BUT If I use PIPE for both (so I can .write() on the stdin and .read() > from the subprocess' stdout stream (better: file descriptor)) reading > from the subprocess stdout blocks forever. If I write something onto > the subprocess

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-01 Thread George Trojan
[EMAIL PROTECTED] wrote: > Okay, here is what I want to do: > > I have a C Program that I have the source for and want to hook with > python into that. What I want to do is: run the C program as a > subprocess. > The C programm gets its "commands" from its stdin and sends its state > to stdout. Th

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-01 Thread bayer . justin
Okay, here is what I want to do: I have a C Program that I have the source for and want to hook with python into that. What I want to do is: run the C program as a subprocess. The C programm gets its "commands" from its stdin and sends its state to stdout. Thus I have some kind of dialog over stdi

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-01 Thread Gabriel Genellina
En Wed, 28 Feb 2007 18:27:43 -0300, <[EMAIL PROTECTED]> escribió: > Hi, > > I am trying to communicate with a subprocess via the subprocess > module. Consider the following example: > from subprocess import Popen, PIPE Popen("""python -c 'input("hey")'""", shell=True) > hey > > Her

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-01 Thread bayer . justin
Hi, Thanks for your answer. I had a look into the fcntl module and tried to unlock the output-file, but >>> fcntl.lockf(x.stdout, fcntl.LOCK_UN) Traceback (most recent call last): File "", line 1, in IOError: [Errno 9] Bad file descriptor I wonder why it does work with the sys.stdin It's real

Re: Dialog with a process via subprocess.Popen blocks forever

2007-02-28 Thread Hendrik van Rooyen
<[EMAIL PROTECTED]> wrote: > Is it possible to read to and write to the std streams of a > subprocess? What am I doing wrong? I think this problem lies deeper - there has been a lot of complaints about blocking and data getting stuck in pipes and sockets... I have noticed that the Python file o

Dialog with a process via subprocess.Popen blocks forever

2007-02-28 Thread bayer . justin
Hi, I am trying to communicate with a subprocess via the subprocess module. Consider the following example: >>> from subprocess import Popen, PIPE >>> Popen("""python -c 'input("hey")'""", shell=True) >>> hey Here hey is immediately print to stdout of my interpreter, I did not type in the "hey"