473,398 Members | 2,165 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,398 software developers and data experts.

readline() after popen hangs

Hallo,

here my code:
....
(sin, souterr) = os.popen4(command)
while 1:
line = souterr.readline()
print line
if not line:
break
....

Now I have the problem: the last two lines are written after five
(5!!!) minutes. Why so a long time?

Who has a solution for this problem?
Thank you for your hints, Thomas
Jul 18 '05 #1
1 4203
Thomas Steffen wrote:

here my code:
...
(sin, souterr) = os.popen4(command)
while 1:
line = souterr.readline()
print line
if not line:
break
...

Now I have the problem: the last two lines are written after five
(5!!!) minutes. Why so a long time?


Note that doing "print line" before the check for "not line" doesn't
make sense, as you would then be printing an empty line when in fact
you had reached the end of the data.

You don't show the command involved, so we're just guessing. My
guess is that you are not providing the other program that you
are invoking with the input data that it needs, via sin, and
that after the five minute timeout the program is quitting and
you are getting the final output only as it exits.

Why are you grabbing "sin" if you aren't going to use it?

-Peter
Jul 18 '05 #2

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

Similar topics

0
by: Byrom, R (Rob) | last post by:
hi, When I use: os.popen('ssh -l root@something tomcat4 stop') I find the command always hangs. The 'something' host contains the correct key in the authorized_hosts file and works ok on the...
1
by: Rasmusson, Lars | last post by:
Hi, I have a problem doing I/O in a python thread. I want a thread to execute a command using os.popen, read its input until the end, and then print 'DONE' and terminate. However, the...
2
by: washu | last post by:
Hi, This may be a simple problem but I can't seem to find a way around it. I've pasted my code snippet below: import os input = os.popen("echo hello") input.readline() input.readline()
0
by: David H | last post by:
Background. I'm running on WinXP w/ MS Services for Unix installed (to give rsh/rlogin ability), both Python 2.3 and 2.4 version. In linux, I'm running RHEE with python2.3 version. The code...
2
by: Maarten van Veen | last post by:
A long story made short, I've build a python/cgi website consisting of two pages. Page1 has a html form in which you can input a series of queries. Then via Popen it starts a pythons search script,...
1
by: Horta | last post by:
Hi folks, Sometimes, when I do an os.popen*(), the process executed by the command hangs, and the script stops forever on the readline()/ readlines() calls. I found that I can use select, but I'm...
6
by: gregpinero | last post by:
Let's say I have this Python file called loop.py: import sys print 'hi' sys.stdout.flush() while 1: pass And I want to call it from another Python process and read the value 'hi'. How...
1
by: Marko Rauhamaa | last post by:
This tiny program hangs: ======================================================================== #!/usr/bin/env python import subprocess a = subprocess.Popen('cat',shell = True,stdin =...
0
by: Christian Heimes | last post by:
Kenneth McDonald wrote: The subprocess module has already an API method for your use case. The communicate() method of a subprocess.Popen instance takes an optional stdin string and returns the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.