| | |
Regarding "popen2" module
![]() |
•
•
Join Date: Feb 2008
Posts: 14
Reputation:
Solved Threads: 1
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
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
•
•
Join Date: Dec 2006
Posts: 977
Reputation:
Solved Threads: 273
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
![]() |
Other Threads in the Python Forum
- Previous Thread: Simple code is confusing me
- Next Thread: plz help me with for loop thx
| Thread Tools | Search this Thread |
alarm anydbm app beginner cipher clear cmd conversion coordinates corners cturtle curves cx-freeze data decimals definedlines development directory dynamic events excel feet file float format function generator getvalue halp handling homework http input ip itunes keycontrol leftmouse line linux list lists loan loop maintain matching maze millimeter module mouse number numbers output parsing path prime programming push py2exe pygame pymailer python queue random rational raw_input recursion recursive schedule screensaverloopinactive script searchingfile singleton slicenotation sqlite ssh string strings sudokusolver tails text time tlapse tooltip tuple type ubuntu unicode url urllib urllib2 valueerror variable ventrilo vigenere web webservice wikipedia word wxpython xlwt





