files in non-blocking mode?

U

Uwe Mayer

Hi,

I want two python programs to communicate over stdIO channels. The one
executes the other via the popen3 function:

amc = Popen3("./amc/amc.py", True, 0)
line = stdin.readline()
amc.tochild.write(line)
amc.tochild.flush()
print amc.fromchild.readlines()

The problem is that although amc.tochild gets flushed the data never reaches
the client until the .tochild fd is closed. Is there any way to put IO
channels into non-blocking mode in python?

Thanks
Uwe
 
M

Mathias Waack

Uwe said:
Hi,

I want two python programs to communicate over stdIO channels. The
one executes the other via the popen3 function:

amc = Popen3("./amc/amc.py", True, 0)
line = stdin.readline()
amc.tochild.write(line)
amc.tochild.flush()
print amc.fromchild.readlines()

The problem is that although amc.tochild gets flushed the data
never reaches the client until the .tochild fd is closed. Is there
any way to put IO channels into non-blocking mode in python?

How do you read the data in the client? Maybe you're using a line
buffered read? Does your code work if the server includes a trailing
CR and/or NL in the string before it calls the flush?

Mathias
 
U

Uwe Mayer

How do you read the data in the client? Maybe you're using a line
buffered read? Does your code work if the server includes a trailing
CR and/or NL in the string before it calls the flush?

Yes, I used

line = stdin.readline()

and made sure the sending client had a newline ("\n") char appended to the
text. Still, the receiving client's readline() function does not return.

Uwe
 
J

Jean Brouwers

Try setting the unbuffered mode for the spawned process by using

"python -u ./amc/amc.py"


/Jean Brouwers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top