| | |
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: 1,008
Reputation:
Solved Threads: 285
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 |
address aliased anydbm app bash beginner bits calling casino changecolor cipher clear conversion coordinates corners count cturtle curves definedlines development dictionary digital dynamic events examples excel external feet file float format function gui handling hints homework iframe images import input java keycontrol line linux list lists loan loop matching mouse multiple number numbers output parsing path port prime programming projects py py2exe pygame pymailer python random rational raw_input recursion recursive scrolledtext searchingfile shebang signal singleton split string strings tails terminal text threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable web-scrape whileloop word wxpython xlwt






