Regarding "popen2" module

Reply

Join Date: Feb 2008
Posts: 14
Reputation: dilbert_here00 is an unknown quantity at this point 
Solved Threads: 1
dilbert_here00 dilbert_here00 is offline Offline
Newbie Poster

Regarding "popen2" module

 
0
  #1
Apr 23rd, 2008
Hi All,

Is it possible to flush the buffer of "popen2.Popen3(cmd)"after some time interval?

I am starting a server forever using the popen2 module. After some time the buffer gets full & it stops logging messages.

As a workaround to this, I am redirecting the output of 'cmd' to a file which solves the buffer problem but creates a new one.

Example: out = popen2.Popen3('./server > /log/log.txt')

Now because of the re direction two processes are started & out.pid returns the process id of the file redirection & I am not able to get the process id of "./server" process.

Any help would be greatly appreciated

Thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 977
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 273
woooee woooee is offline Offline
Posting Shark

Re: Regarding "popen2" module

 
0
  #2
Apr 24th, 2008
Have you tried sys.stdout.flush()? I don't know if that will work or not. Also, you want to begin to move over to the subprocess module. Theoretically, it should flush the buffer whenever you issue a read stdout using subprocess. I guess no one else has much to offer on this. A link to Hellman's subprocess PyMOTW http://blog.doughellmann.com/2007/07...ubprocess.html
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 14
Reputation: dilbert_here00 is an unknown quantity at this point 
Solved Threads: 1
dilbert_here00 dilbert_here00 is offline Offline
Newbie Poster

Re: Regarding "popen2" module

 
0
  #3
Apr 25th, 2008
Hey thanks for your help. I tried subprocess & it kind of worked.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC