473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

files in non-blocking mode?

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
Jul 18 '05 #1
3 2164
Uwe Mayer wrote:
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
Jul 18 '05 #2
Sunday 28 November 2004 14:49 pm Mathias Waack wrote:
Uwe Mayer wrote:
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?


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
Jul 18 '05 #3

Try setting the unbuffered mode for the spawned process by using

"python -u ./amc/amc.py"
/Jean Brouwers
In article <co**********@news2.rz.uni-karlsruhe.de>, Uwe Mayer
<me*****@hadiko.de> wrote:
Sunday 28 November 2004 14:49 pm Mathias Waack wrote:
Uwe Mayer wrote:
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?


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

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: MAK | last post by:
Hello everyone, I know how to add images and icons etc to dll file. What I would like to know is there is a way to add those icons on the forms during the run time from the dll or to reference it ...
5
by: Anand K Rayudu | last post by:
Hi all, I am trying to find a way to get the files recursively in a given directory, The following code is failing, can some one please suggest what could be problem here from os import...
2
by: Tim Blizard | last post by:
I know this topic has been discussed before but I couldn't find any thread more recent than about 18 months and was interested in what conclusions people had come to recently. Invariably 3...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
1
by: Xiangliang Meng | last post by:
Hi, all. Recently, I find there is a way in our project to maintain a global set in many files by using preprocessing directives. I'm wondering if we could find a better method for this. Many...
4
by: aaj | last post by:
Hi all I have a group of files that I store independently in a temporary folder on the c: drive. Typical things are ini files, bitmaps, icons etc. All access to the files is hardcoded within my...
14
by: padh.ayo | last post by:
Can C open (and keep open) two files at any given time? so, FILE *a, *b; a = fopen(argv, "r"); b = fopen(argv, "r"); ?
13
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives,...
12
by: bg_ie | last post by:
Hi, I'm updating my program to Python 2.5, but I keep running into encoding problems. I have no ecodings defined at the start of any of my scripts. What I'd like to do is scan a directory and...
17
by: byte8bits | last post by:
How does C++ safely open and read very large files? For example, say I have 1GB of physical memory and I open a 4GB file and attempt to read it like so: #include <iostream> #include <fstream>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.