DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   Regarding "popen2" module (http://www.daniweb.com/forums/thread120650.html)

dilbert_here00 Apr 23rd, 2008 4:37 pm
Regarding "popen2" module
 
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

woooee Apr 24th, 2008 12:00 am
Re: Regarding "popen2" module
 
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

dilbert_here00 Apr 25th, 2008 1:00 am
Re: Regarding "popen2" module
 
Hey thanks for your help. I tried subprocess & it kind of worked.


All times are GMT -4. The time now is 11:56 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC