Re: Tuning a select() loop for os.popen3()



In article <mailman.2735.1135972050.18701.python-list@xxxxxxxxxx>,
Christopher DeMarco <cmd@xxxxxxxxxxxx> wrote:

> I've written a class to provide an interface to popen; I've included
> the actual select() loop below. I'm finding that "sometimes" popen'd
> processes take "a really long time" to complete and "other times" I
> get incomplete stdout.

....

> My first question, then, is paranoid: I've run all these benchmarks
> because the application using this code saw a HUGE performance hit
> when we started using popen'd commands which generated "lots of"
> output.
>
> Is there anything wrong with the logic in my code?!

I tried a modified version with 'ls -R .', which yields about
1 Mb of data, and saw no problems on MacOS X. Same data, and
about the same time as 'ls -R .' from the shell, maybe 5% longer.

But I modified it a lot. I removed every "continue", I removed
the "break", and I made readList the condition for the while loop.
With these changes, a 0.1 second timeout is about the same as no
timeout, but at 0.01 second I do see a little slow down. Still
no loss of data.

I suspect there is indeed something wrong with your logic, but
I'm not going to try to figure it out. If you're sure it's
right, I think you should post again with the actual code for
a program that demonstrates your problem(s). Your goal for the
revised logic should be 1) avoid gratuitous branches in the flow
of control, 2) reduce number of state variables that you have to
account for, and 3) express your intentions clearly with respect
to the timeouts -- what do you do when it times out, and why?

Donn Cave, donn@xxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: Threading a server
    ... SMTP. ... needed the watchdog and with a reasonable amount of time. ... I am guessing that to deal with the timeout behaviour, ... The next message you posted commented on the loop. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Form OnKeypress event not firing while test loop running
    ... Paul E. Schoen wrote: ... Once this happens the display shows the running time and current value, and this may be repeated until a certain number of pulses occur, or a preset timeout is reached. ... The data analysis is accomplished in a rather large loop which fires on a 200 mSec timer event, and it processes about 480 integer data values. ... ESC key for example, then while your in that loop, you can test for that value incase the user wants to terminate the current function.. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Need Help in Loop Foreach
    ... I'd like to insert a loop, in such a way that it reads all the "System ID" ... # Query all the systems status by inputting the SystemIDs on Expect Script ... intial expect until a timeout occured. ... # may want to break after sending exit in above section if this does ...
    (comp.lang.tcl)
  • Re: creating a new thread to run while loop
    ... > connection suddenly dropped, so i have to go for an alternative which ... thread) is not able to timeout / return error / etc and is basically being ... The only options seems to be to terminate the ... The example that you supplied w/ the loop in the main thread that causes the ...
    (microsoft.public.windowsce.embedded.vc)
  • TimeOut Expired. Using Temporary tables
    ... I am iterating through these records in a WHILE Loop and performing certain business rules on these records. ... This entire processing is being done in a stored procedure which is being executed using ADO.NET's ExecuteNonQuery method. ... However after around 18 hrs of processing time i get a TimeOut error. ... Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching. ...
    (microsoft.public.dotnet.framework.adonet)